You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PR adds HTTP header customization support for LLM API requests across OpenAI, Anthropic, and Google backends with both global and per-request configuration options, but the inject_headers function in the Google GenAI client silently ignores unsupported http_options types instead of raising an error.
The inject_headers function only handles dict and HttpOptions types for http_options. If http_options is any other type, the function silently does nothing, which could lead to headers not being injected without any warning or error. This is a potential bug where the caller expects headers to be injected but they are not. Tags: bug Affected code:
66: definject_headers(headers: Mapping[str,str], params: dict) ->None:
67: """68: Inject extra HTTP headers into the params dictionary for Google GenAI client.69: """70: if"http_options"notinparams:
71: params["http_options"] = {}
72: http_options=params["http_options"]
73: ifisinstance(http_options, dict):
74: if"headers"notinhttp_options:
75: http_options["headers"] = {}
76: http_options["headers"].update(headers)
77: elifisinstance(http_options, HttpOptions):
78: ifhttp_options.headersisNone:
79: http_options.headers= {}
80: http_options.headers.update(headers)
Proposed change:
definject_headers(headers: Mapping[str, str], params: dict) ->None:
""" Inject extra HTTP headers into the params dictionary for Google GenAI client. """if"http_options"notinparams:
params["http_options"] = {}
http_options=params["http_options"]
ifisinstance(http_options, dict):
if"headers"notinhttp_options:
http_options["headers"] = {}
http_options["headers"].update(headers)
elifisinstance(http_options, HttpOptions):
ifhttp_options.headersisNone:
http_options.headers= {}
http_options.headers.update(headers)
else:
raiseTypeError(f"Unsupported http_options type: {type(http_options)}")
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
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.
Features: