Skip to content

fix(cli): stop returning exception text from session 400s and finalize credentials - #8340

Draft
ishan-1010 wants to merge 2 commits into
google:mainfrom
ishan-1010:fix-error-text-followup
Draft

ishan-1010 wants to merge 2 commits into
google:mainfrom
ishan-1010:fix-error-text-followup

Conversation

@ishan-1010

Copy link
Copy Markdown
Contributor

Follow up to #8251 for the 4xx paths in #8250. The session create 400 and the /agent-identity/finalize route still put the exception text in the response. That text can carry the server's own engine id, stored state errors or upstream resource names. They now use the same redaction as the 500 paths, a fixed message plus an error id, and the real text only shows with ADK_DEBUG_ERRORS.

This is stacked on #8251, so the first commit here is that PR. Only the top commit is new. I can rebase once #8251 merges.

Link to issue

Refs #8250

What changed

  • Session create 400 uses a fixed "Invalid session create request." and an error id
  • Finalize credentials uses fixed messages for the 400 (InvalidArgument), for GoogleAPICallError (same status code as before) and for the generic 500
  • 4xx responses are logged at warning level since the caller caused them, 5xx stay at error level through report_error

Left alone on purpose

The base64 400 in finalize still returns its message, since that is only the caller's own input.

Testing plan

Added cases to tests/unittests/cli/test_api_server_error_leak.py. They fail without the change (6 failed, 3 passed) and pass with it (9 passed).

  1. Session service raises ValueError with a Vertex engine id, expect a 400 without the id and with an error id
  2. Same for the corrupt stored state message
  3. ADK_DEBUG_ERRORS=1 brings the text back on the 400
  4. Finalize with InvalidArgument, PermissionDenied, InternalServerError and a plain RuntimeError, expect the same status codes as before, no secret in the body and an error id

The finalize tests fake the optional agent-identity package. pyink and isort pass. I could not run the rest of tests/unittests/cli locally because of optional dependencies. The two existing finalize tests in test_fast_api.py only check for the "Invalid credentials request" and "Failed to finalize credentials" text, which is still in the new messages, but I am relying on CI to confirm.

The generic except in create_session put str(e) in the response, so a
failing session service could hand its paths or database URL to the
caller. Use report_error like the A2A executors and trigger routes do.

Refs google#8250
…e credentials

The session create 400 branch and the /agent-identity/finalize route put
the exception text in the response. The text can carry the server's own
engine id, stored state errors or upstream resource names. Send them
through the same redaction as the 500 paths. 4xx responses are logged as
warnings, 5xx as errors.

Refs google#8250
@ishan-1010

Copy link
Copy Markdown
Contributor Author

stacked on #8251 so the first commit here is that one. once it merges i'll rebase and mark this ready for review. fyi @surajksharma07

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