Reputation: 11508
Deploying Google Cloud Functions from the local system fails with the following error:
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function load error: File main.py that is expected to define function doesn't exist
I've used the console UI to check the contents of the package that was uploaded in the failed deployment and the file is present. The package was created using the gcloud
CLI:
gcloud functions deploy <redacted> \
--trigger-http \
--runtime=python37 \
--region=europe-west1 \
--project=<redacted> \
--entry-point=<redacted>
For context, the same project was deployed successfully multiple times by several people but started failing for everyone new that checked it out after a specific date.
Upvotes: 3
Views: 6388
Reputation: 377
I solved this problem in my application in Node.js, basically I identified that the .gcloudignore
file it invokes the .gitignore
of the project, so if your function is in a skipped folder it simply does not find, then just remove the line #! Include : .gitignore
file .gcloudignore
Upvotes: 1
Reputation: 11508
In our case, this was because of invalid credentials, i.e. the JSON file passed to ServiceAccountCredentials.from_json_keyfile_name
was missing. Confusingly, the error doesn't mention anything about security, credentials or that missing file.
Secrets are not in version control and the shared vault had a stale file that did not match the path provided in the python script. This was fixed once the credentials were corrected.
We managed to isolate the problem to the authenticated call by successfully deploying 'dumb' functions (return a string) and then incrementally adding back functionality until it broke.
Upvotes: 4