Skip to content

fix(cli): gate --sandbox-launcher behind gcloud beta run deploy - #6514

Open
abhiramArise wants to merge 1 commit into
google:mainfrom
abhiramArise:fix-cloud-run-sandbox-launcher-flag
Open

fix(cli): gate --sandbox-launcher behind gcloud beta run deploy#6514
abhiramArise wants to merge 1 commit into
google:mainfrom
abhiramArise:fix-cloud-run-sandbox-launcher-flag

Conversation

@abhiramArise

@abhiramArise abhiramArise commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem:
adk deploy cloud_run unconditionally appends --sandbox-launcher to the gcloud run deploy command it constructs. That flag is only valid on the beta release track (gcloud beta run deploy) — it is not recognized on the GA track. As a result, every adk deploy cloud_run invocation fails with:

ERROR: (gcloud.run.deploy) unrecognized arguments: --sandbox-launcher

Solution:
Added an opt-in --with_cloud_run_sandbox CLI flag on adk deploy cloud_run:

  • When not set (default): the constructed gcloud command matches the pre-regression GA behavior, with --sandbox-launcher removed entirely.
  • When set: the command is built as gcloud beta run deploy ... --sandbox-launcher, correctly targeting the release track that actually supports the flag.

This keeps the default (and most common) path working out of the box, while preserving sandbox support for users who explicitly want it.

# Standard deployment (GA track, no sandbox)
adk deploy cloud_run --project=PROJECT --region=REGION path/to/agent

# Deployment with Cloud Run sandbox for code execution (beta track)
adk deploy cloud_run --with_cloud_run_sandbox --project=PROJECT --region=REGION path/to/agent

Testing Plan###

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Added test_to_cloud_run_with_sandbox (parametrized True/False) in test_cli_deploy_to_cloud_run.py, verifying:

  • with_cloud_run_sandbox=False → no beta inserted, no --sandbox-launcher in the command
  • with_cloud_run_sandbox=Truebeta inserted immediately after the gcloud binary, --sandbox-launcher present in the command

Updated test_to_cloud_run_happy_path to remove the now-incorrect assertion that --sandbox-launcher is always present.

tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_happy_path[True-True] PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_happy_path[True-False] PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_happy_path[False-True] PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_happy_path[False-False] PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_cleans_temp_dir PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_cleans_temp_dir_on_failure PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_with_sandbox[True] PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_to_cloud_run_with_sandbox[False] PASSED
tests/unittests/cli/utils/test_cli_deploy_to_cloud_run.py::test_cloud_run_label_merging[...] PASSED (7 cases)

15 passed, 8 warnings in 6.11s

I also ran the full tests/unittests/cli/ suite. One pre-existing failure, test_telemetry_cli_commands, is unrelated to this change — confirmed via git stash that it fails identically on unmodified main, before any of these changes are applied.

Manual End-to-End (E2E) Tests:
Verified via the constructed gcloud_cmd argument lists in unit tests (mocked subprocess.run) rather than an actual Cloud Run deployment, since that requires a live GCP project/billing account. Manually traced the logic against the [official Cloud Run sandbox docs](https://docs.cloud.google.com/run/docs/code-execution), which confirm --sandbox-launcher is a gcloud beta run deploy-only flag.

Checklist###

  • I have read the [CONTRIBUTING.md]
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context###

Regression traced to commit 5b1088a. Reported in #6511 by @KenTandrian with exact reproduction steps and logs, which made root-causing this straightforward.

@adk-bot adk-bot added the tools [Component] This issue is related to tools label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools [Component] This issue is related to tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADK Cloud Run deployment fails with unrecognized argument '--sandbox-launcher' on gcloud GA track

3 participants