collab-staging: google_ai: Classify invalid API keys as authentication errors (#65885)
Summary
Google AI returns HTTP 400 / INVALID_ARGUMENT for invalid API keys,
which the shared HTTP classifier treats as an invalid request rather
than an authentication failure.
- Classify these responses as
Authenticationusing the structured
API_KEY_INVALIDreason, with a fallback for Google's known invalid-key
message. - Preserve the original HTTP status, provider code, and message.
- Keep unrelated HTTP 400 responses classified as
InvalidRequest.
This applies to both model listing and streaming completions through
their shared response classifier.
Fixes DELTA-1C2
Verification
cargo fmt -p google_ai --checkgit diff --checkcorgi test -p google_ai --lib 'provider_error_tests::'β all 3 tests
passed.- Queried Google's live model-listing and streaming-completion endpoints
with an intentionally invalid key. Both returned HTTP 400,
INVALID_ARGUMENT, and the structuredAPI_KEY_INVALIDreason. - Passed the actual streaming response body through
completion_error_from_responsein a temporary test and verified it
classified asAuthentication. Removed the temporary test afterward;
permanent tests cover structured reasons, the message fallback, and
unrelated invalid requests.
Release Notes:
- Fixed Google AI invalid API keys being classified as invalid requests
instead of authentication errors.