❌

Lees weergave

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 Authentication using the structured
    API_KEY_INVALID reason, 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 --check
  • git diff --check
  • corgi 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 structured API_KEY_INVALID reason.
  • Passed the actual streaming response body through
    completion_error_from_response in a temporary test and verified it
    classified as Authentication. 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.

  •  
❌