fix(gateway): guard against None request_overrides in _build_api_kwargs - #17032
Merged
Conversation
Contributor
🚨 CRITICAL Supply Chain Risk DetectedThis PR contains a pattern that has been used in real supply chain attacks. A maintainer must review the flagged code carefully before merging. 🚨 CRITICAL: Install-hook file added or modifiedThese files can execute code during package installation or interpreter startup. Files: Scanner only fires on high-signal indicators: .pth files, base64+exec/eval combos, subprocess with encoded commands, or install-hook files. Low-signal warnings were removed intentionally — if you're seeing this comment, the finding is worth inspecting. |
3 tasks
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.
Summary
Salvage of #7305 by @konsisumer — normalizes
request_overridesfromNoneto{}at the source in gateway/run.py so downstream code never encounters NoneType.Closes #7215, closes #7259, closes #7277
Background
Commit 970192f (fast mode support) introduced
request_overridesplumbing in the gateway. Three sites in_resolve_turn_agent_configcould produceNone:route["request_overrides"] = Noneresolve_fast_mode_overrides()raises →overrides = Noneturn_route.get("request_overrides")which can beNoneThis caused
AttributeError: 'NoneType' object has no attribute 'get'on every gateway message for users without fast mode configured.The acute crash was already mitigated by PR #7350 (added
or {}at the access site in_build_api_kwargs). This PR fixes the root cause — the gateway now always produces{}instead ofNone, preventing any future consumer from hitting the same bug.Changes
gateway/run.py: Three sites in_resolve_turn_agent_confignormalized fromNoneto{}tests/gateway/test_fast_command.py: Updated assertion fromis Noneto== {}tests/run_agent/test_provider_parity.py: New test for_build_api_kwargswithrequest_overrides = NoneAll 4 targeted tests pass. Clean cherry-pick, no conflicts (only 19 commits behind main).