I am getting the following error since this morning but nothing changed regarding my code (just added a log.println()... Even getting back to a previous version that was deployed doesn't solve the issue)
trigger.go (entry point)
// The function that runs with the cloud function itself
func HandleUserCreateEvent(ctx context.Context, e my_project.FirestoreEvent) error {
log.Println("-------------------- oldValue --------------------")
log.Printf("Name: %s\n", e.OldValue.Name)
log.Printf("CreateTime: %v\n", e.OldValue.CreateTime)
log.Printf("Fields: %v\n", e.OldValue.Fields)
log.Printf("UpdateTime: %v\n", e.OldValue.UpdateTime)
log.Println("-------------------- newValue --------------------")
log.Printf("Name: %s\n", e.Value.Name)
log.Printf("CreateTime: %v\n", e.Value.CreateTime)
log.Printf("Fields: %v\n", e.Value.Fields)
log.Printf("UpdateTime: %v\n", e.Value.UpdateTime)
log.Println("-------------------- jsonValue -------------------")
jsonB, _ := json.Marshal(e.Value)
log.Printf("Json: %v\n", string(jsonB))
log.Println("---------------------- DONE ----------------------")
// My code
return nil
deploy.sh (having also a deploy.bat which was working as well as the sh script below)
#!/usr/bin/env bash
# Deployment automation
name="HandleUserCreateEvent"
projectId="my_project"
collection="UsersCollection"
# Must call go vendor as go modules are ignored
go mod vendor
yes Y | gcloud functions deploy ${name} \
--trigger-event providers/cloud.firestore/eventTypes/document.create \
--trigger-resource "projects/${projectId}/databases/(default)/documents/${collection}/{pushId}" \
--region europe-west1 \
--runtime go113 \
--allow-unauthenticated \
--memory 128
As this was working perfectly, now it doesn't anymore (as stated, I just added the jsonValue part of the code you see above)
Error
MacBook-Pro-de-Emixam23:my-project-elasticsearch-creater emixam23$ ./deploy.sh
Deploying function (may take a while - up to 2 minutes)...
....................................................failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: # serverless_function_app/main
src/serverless_function_app/main/main.go:24:38: cannot use my_project_elasticsearch_creater.HandleUserCreateEvent (type func(context.Context, my_project_elasticsearch.FirestoreEvent) error) as type func(http.ResponseWriter, *http.Request) in argument to funcframework.RegisterHTTPFunction; Error ID: 6191efcd
Any idea? I really think that gcloud has some issues...
Update -> gcloud is really broken
I just redeployed an empty function, with only a simple struct as package with no dependencies (go modules empty)
type FirestoreEvent struct {
OldValue interface{} `json:"oldValue"`
Value interface{} `json:"value"`
UpdateMask struct {
FieldPaths []string `json:"fieldPaths"`
} `json:"updateMask"`
}
Still the same issue
C:\Workspace\go\src\gitlab-group\my-project-elasticsearch-creater>gcloud --version
Google Cloud SDK 298.0.0
app-engine-go
app-engine-python 1.9.91
bq 2.0.58
cloud-datastore-emulator 2.1.0
core 2020.06.19
gsutil 4.51