'ERROR: (gcloud.beta.functions.deploy) Invalid Cloud Source Repository URL provided when using cloud function gen2

I am trying out cloud functions gen2, but somehow the cloudbuild that builds the function cannot find the cloud source repository URL. This seems undocumented in the official doc from google cloud.

The same function deploys without an issue when I remove the --gen2 tag in the deploy command, so I am sure it doesn't come from my code.

cloudbuild.yaml

steps:
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  args:
  - gcloud
  - beta
  - functions
  - deploy
  - ${_SERVICE_NAME}
  - --project=${_PROJECT}
  - --region=${_REGION}
  - --source=${_REPOSITORY_PATH}
  - --trigger-bucket=${_TRIGGER_BUCKET_NAME}
  - --runtime=python39
  - --memory=128MB
  - --entry-point=${_ENTRY_POINT}
  - --service-account=${_SERVICE_ACCOUNT}
  - --set-env-vars=OUTPUT_BUCKET_NAME=${_OUTPUT_BUCKET_NAME}
  - --gen2 # When I remove this, the function deploys without an issue.
options:
  logging: 'CLOUD_LOGGING_ONLY'

Source path: _REPOSITORY_PATH

https://source.developers.google.com/projects/muse-speech-devops/repos/github_bbreton-muse_muse_notion_speech_integration/moveable-aliases/dev/paths//functions/launch_transfer

Cloudbuild error

ERROR: (gcloud.beta.functions.deploy) Invalid Cloud Source Repository URL provided. 

Must match the following format: 

https://source.developers.google.com/projects/<projectId>/repos/<repoName>. 

Specify the desired branch by appending /moveable-aliases/<branchName>, 

the desired tag with /fixed-aliases/<tagName>, 

or the desired commit with /revisions/<commit>.


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source