fix(gateway): guard request_overrides None crash in message flow - #8176
Closed
atongrun wants to merge 2 commits into
Closed
fix(gateway): guard request_overrides None crash in message flow#8176atongrun wants to merge 2 commits into
atongrun wants to merge 2 commits into
Conversation
3 tasks
Contributor
|
Thanks for this careful bug report and fix, @atongrun! After reviewing Automated hermes-sweeper review — verifying against current
The one gap (gateway's direct attribute assignment at |
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.
What does this PR do?
Fixes a gateway crash path where
turn_route.get("request_overrides")can beNone, but downstream agent code assumes a dict and calls.get("speed"). In messaging flows this breaks request construction before the provider call and can also trigger a secondaryapi_kwargserror while handling the failure.Related Issue
Fixes #
Type of Change
Changes Made
gateway/run.py, normalizeturn_route.get("request_overrides")to an empty dict before assigning it to the cached agent.run_agent.py, guard the Anthropicfast_modelookup with an empty-dict fallback.run_agent.py, initializeapi_kwargs = Nonebefore the retry loop and only dump API request debug data when it exists, preventing a secondaryUnboundLocalErrorfrom masking the original failure.How to Test
turn_routeomitsrequest_overridesor returnsNone.GatewayRunner._run_agent().NoneType object has no attribute getin_build_api_kwargsand does not emit the secondaryUnboundLocalErrorforapi_kwargs.Checklist
Code
pytest tests/ -qand all tests passDocumentation & Housekeeping
Screenshots / Logs
Observed failure before the fix in a live gateway session:
AttributeError: NoneType object has no attribute getatrun_agent.pywhile building API kwargsUnboundLocalErrorforapi_kwargsduring error handling