Cloud Functions "Build failed: function ... entry point not found" in CI
The Cloud Functions build looked for the function named by --entry-point and could not find a matching exported symbol in the deployed source. The build fails before the function is ever created.
What this error means
gcloud functions deploy fails with "Build failed: ... function 'X' is not defined in the provided code" or "entry point not found", where X is the --entry-point you passed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed:
function 'handler' is not defined in the provided code. Did you specify the right
entry point? Please visit https://cloud.google.com/functions/docs/troubleshootingCommon causes
The entry point name does not match the export
The function is exported under a different name than the --entry-point value (a typo, or the source defines main while CI passes handler).
The handler is not exported from the expected file
For Node the symbol must be on exports/module.exports; for Python it must be a top-level function in main.py. A nested or unexported function is not found.
How to fix it
Match --entry-point to the exported symbol
- Open the source and note the exact exported function name.
- Pass that name to --entry-point on the deploy command.
- Redeploy and confirm the build finds the function.
gcloud functions deploy api \
--runtime python312 --trigger-http --entry-point mainExport the handler at the top level
Ensure the function is exported from the entry file the runtime expects (main.py for Python, index.js for Node).
# main.py (Python runtime)
def main(request):
return "ok"How to prevent it
- Keep the --entry-point value in sync with the exported function name.
- Define handlers as top-level exports in the runtime entry file.
- Deploy from the directory that actually contains the source.