Skip to content

Fix: map the ADK log level to a legal gcloud verbosity in deploy cloud_run - #698

Open
AmaadMartin wants to merge 2 commits into
mainfrom
fix/cloud-run-gcloud-verbosity-mapping
Open

Fix: map the ADK log level to a legal gcloud verbosity in deploy cloud_run#698
AmaadMartin wants to merge 2 commits into
mainfrom
fix/cloud-run-gcloud-verbosity-mapping

Conversation

@AmaadMartin

@AmaadMartin AmaadMartin commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

  1. Link to an existing issue (if applicable):

  2. Or, if no issue exists, describe the change:

Problem: adk deploy cloud_run --log_level warn always fails. The ADK CLI accepts debug|info|warn|error, but gcloud's --verbosity accepts critical|debug|error|info|none|warning. prepareGCloudArguments forwarded the ADK level verbatim, so gcloud rejected --verbosity warn during argument parsing and the deploy aborted before it reached GCP. The user only saw Failed to deploy to Cloud Run: Command failed with exit code 2, which does not name the log level as the cause.

Solution: I translate the ADK log level to a gcloud verbosity at the single point of use. The lookup falls back to info for any value outside the ADK vocabulary, so the argv can never carry an illegal verbosity. I chose a fallback over a throw for two reasons: a throw replaces one broken deploy with a different broken deploy, and the ADK CLI already resolves an unrecognized log level to INFO everywhere else (cli.ts:47). The translation happens at the gcloud boundary only, so the generated Dockerfile keeps the raw ADK level for the ADK server inside the container.

Notes for the reviewer:

Testing Plan

Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.

Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.

npx vitest run --project unit:dev dev/test/cli/cli_deploy_cloud_run_test.ts -> 34 passed. I added 7 cases and edited none of the 27 existing ones.

Coverage. The new code (the table at cli_deploy_cloud_run.ts:60-69 and the call site at :104) has 100% line and branch coverage; both sides of the ?? are exercised. The file as a whole reports 95.53% statements / 89.13% branches. The shortfall is entirely pre-existing uncovered code (lines 74, 119, 152-155, 187, 191) that this change does not touch.

Proof the tests can fail. I ran each new test against mutated source and confirmed it fails.

Mutation Tests that failed Message
Restore options.logLevel.toLowerCase() on the --verbosity line warn->warning, upper-case, unknown-level fallback expected 'warn' to be 'warning', expected 'trace' to be 'info'
Translate by assigning the result back into options.logLevel Dockerfile keeps the raw level expected '\nFROM node:lts-alpine...' to contain '--log_level='warn''
Change the table entry to 'debug': 'critical' debug passthrough expected 'critical' to be 'debug'
Drop the ?? 'info' fallback unknown-level fallback expected undefined to be 'info'

The second mutation is the one worth calling out: it is the in-place variant that looks idiomatic here, because the function already mutates options.project and options.region. It would leak the gcloud spelling into the container command line, and that test is the guard against it.

Manual End-to-End (E2E) Tests:

The failure is in argv construction, and gcloud validates --verbosity during argument parsing, before authentication. So this reproduces offline with no GCP project. Against Google Cloud SDK 579.0.0:

$ gcloud version --verbosity=warn
ERROR: (gcloud.version) argument --verbosity: Invalid choice: 'warn'. Did you mean 'warning'?
$ echo $?
2

$ gcloud version --verbosity=warning
Google Cloud SDK 579.0.0
$ echo $?
0

The full choice list comes from the same SDK: gcloud version --verbosity=bogus reports Valid choices are [critical, debug, error, info, none, warning].

To exercise the CLI end to end: npm install && npm run build, then adk deploy cloud_run --project any-project --region us-central1 --log_level warn ./path/to/agent. Before this change the deploy aborts on the rejected argument; after it, gcloud accepts the argv and proceeds.

Checklist

[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.

Amaad Martin added 2 commits August 5, 2026 22:13
…d_run

gcloud's --verbosity accepts critical|debug|error|info|none|warning. The
ADK CLI accepts debug|info|warn|error. `adk deploy cloud_run --log_level
warn` forwarded 'warn' verbatim, so gcloud rejected the argument and the
whole deploy failed before it reached GCP.

Translate at the single point of use. The generated Dockerfile keeps the
raw ADK level, because the ADK server inside the container speaks the ADK
vocabulary.
The toGcloudVerbosity wrapper had one caller and wrapped a constant
declared directly above it. Inlining the lookup at the call site matches
the shape cli.ts:47 already uses for the same problem.

The fallback test asserted the result was a member of a hardcoded list
that contained the literal the preceding line already pinned, so the
assertion could not fail. The toBe('info') assertion above it pins the
fallback on its own.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant