Skip to content

fix(codex): keep streamed Gemini argument errors request scoped - #2904

Merged
jlcodes99 merged 1 commit into
jlcodes99:mainfrom
jamie950315:fix/codex-gemini-request-scope
Oct 27, 2026
Merged

jlcodes99 merged 1 commit into
jlcodes99:mainfrom
jamie950315:fix/codex-gemini-request-scope

Conversation

@jamie950315

Copy link
Copy Markdown
Contributor

Summary

Treat the observed streamed Gemini rejection Request contains an invalid argument. as request-scoped when it reaches the gateway as a 5xx failure without authentication metadata.

Problem

An upstream Gemini stream can return HTTP 200, then emit an error containing only:

{"type":"error","error":{"message":"Request contains an invalid argument."}}

Cockpit reports this as a gateway 502. Because the envelope has no usable request-error code, the existing classifier treats it as an account failure and applies a model cooldown. Subsequent retries can exhaust the available routes and replace the original request error with No compatible account is available for this model.

Change

  • Recognize the provider's exact rejection message, ignoring case and surrounding whitespace, on gateway 5xx failures without authentication metadata.
  • Mark the failure request-scoped so account cooldown reporting skips it.
  • Preserve the failed response's status and message; the caller still receives the upstream request failure.
  • Keep authentication, quota, model-availability, and genuine server-failure handling unchanged. Broad errors merely mentioning an argument do not match.

This change is independent of the tool-identity fix in #2901, account-model routing in #2902, and the upstream Argon continuation repair in router-for-me/CLIProxyAPI#6935.

Validation

  • cargo test --manifest-path src-tauri/Cargo.toml --lib upstream_errors::tests
  • cargo test --manifest-path src-tauri/Cargo.toml --lib native_connection_failures_do_not_cool_accounts_or_shorten_existing_cooldown
  • cargo test --manifest-path src-tauri/Cargo.toml --lib native_actual_upstream_failures_keep_auth_quota_and_server_cooldowns
  • rustfmt --check --edition 2021 on the two changed Rust files
  • git diff --check

Regression coverage includes streamed error observation, unchanged failure status/message, skipped account cooldowns, and preserved authentication/quota/server cooldown behavior. Tests use synthetic fixtures; no private request logs or credentials are included.

@jlcodes99
jlcodes99 merged commit 719c12d into jlcodes99:main Oct 27, 2026
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.

2 participants