Skip to content

fix(gateway): guard against None request_overrides in _build_api_kwargs - #17032

Merged
kshitijk4poor merged 1 commit into
mainfrom
salvage/request-overrides-none-guard
Apr 28, 2026
Merged

fix(gateway): guard against None request_overrides in _build_api_kwargs#17032
kshitijk4poor merged 1 commit into
mainfrom
salvage/request-overrides-none-guard

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Summary

Salvage of #7305 by @konsisumer — normalizes request_overrides from None to {} 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_overrides plumbing in the gateway. Three sites in _resolve_turn_agent_config could produce None:

  1. No service tier configured → route["request_overrides"] = None
  2. resolve_fast_mode_overrides() raises → overrides = None
  3. Cached agent path directly assigns turn_route.get("request_overrides") which can be None

This 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 of None, preventing any future consumer from hitting the same bug.

Changes

  • gateway/run.py: Three sites in _resolve_turn_agent_config normalized from None to {}
  • tests/gateway/test_fast_command.py: Updated assertion from is None to == {}
  • tests/run_agent/test_provider_parity.py: New test for _build_api_kwargs with request_overrides = None

All 4 targeted tests pass. Clean cherry-pick, no conflicts (only 19 commits behind main).

@kshitijk4poor
kshitijk4poor merged commit e4b69bf into main Apr 28, 2026
9 of 11 checks passed
@kshitijk4poor
kshitijk4poor deleted the salvage/request-overrides-none-guard branch April 28, 2026 13:57
@github-actions

Copy link
Copy Markdown
Contributor

🚨 CRITICAL Supply Chain Risk Detected

This 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 modified

These files can execute code during package installation or interpreter startup.

Files:

hermes_cli/setup.py

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.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

3 participants