fix: suppress Authorization: Bearer for Gemini provider to prevent HT…#8530
Closed
AviArora02-commits wants to merge 1 commit into
Closed
fix: suppress Authorization: Bearer for Gemini provider to prevent HT…#8530AviArora02-commits wants to merge 1 commit into
AviArora02-commits wants to merge 1 commit into
Conversation
Contributor
|
Merged via PR #11961 (commit 994faac on main) — your fix was the most complete, covering all five client-construction sites across Small delta from your original branch: the two existing tests you updated in |
This was referenced Apr 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7893
Root Cause
Google's OpenAI-compatible endpoint (
generativelanguage.googleapis.com/v1beta/openai)does not accept
Authorization: Bearerfor AIzaSy API keys. The OpenAI Python SDKautomatically injects this header whenever a real key is passed as
api_key=, causing:Fix
When
base_urltargetsgenerativelanguage.googleapis.com, the OpenAI client isnow constructed with
api_key="not-used"(suppresses Bearer injection) and the realkey is passed via
default_headers={"x-goog-api-key": real_key}instead.Applied to all 4 client construction paths:
run_agent.py— primary agent client initrun_agent.py—_apply_client_headers_for_base_url()(provider swap/recovery)agent/auxiliary_client.py—_resolve_api_key_provider()pool + main pathsagent/auxiliary_client.py—resolve_provider_client()API-key branchTests
Added 2 regression tests asserting
api_key == "not-used"andx-goog-api-key == real_key. Updated 2 existing tests that wereasserting the old broken auth behavior.