fix(gateway): inherit the parent platform for a nested home_channel mapping #137929
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.57) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 576 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.380
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #137929"
general
weight: 0.35
PRATHAMESH75
What does this PR do?
hermes config set platforms.<name>.home_channel.<field> <value>persists a partial mapping ({chat_id, name}with noplatformkey).HomeChannel.from_dict()indexeddata["platform"]bare, so theKeyErrorescapedby_platform()'sexcept ValueErrorrecovery and aborted the wholeGatewayConfig.from_dict()— the write succeeded, everything kept working until the next restart, and then the gateway process died withKeyError: 'platform'(~1 s after boot; on a supervised host this burns the supervisor's restart budget).The
platformkey is redundant for ahome_channelnested under its own platform block — the parent key already says which platform it is. This PR passes the parent platform down and inherits it when the key is absent. A mapping that names neither source (or is missingchat_id) now raises a descriptiveValueError, whichby_platform()already treats as recoverable: the malformed block is skipped instead of killing the load.Related Issue
Fixes #137919
Type of Change
Changes Made
gateway/config.py—HomeChannel.from_dict(data, , default_platform=None): use an explicitplatformwhen present, else inheritdefault_platform; raise a descriptiveValueError(not a bareKeyError) when neither exists orchat_idis missing.gateway/config.py—PlatformConfig.from_dict(data, , platform=None): accepts the parent platform and hands it toHomeChannel.from_dictasdefault_platform.gateway/config.py—by_platform(..., with_platform=True): resolves thePlatformonce and passes it to the parser; theplatforms=call site opts in.tests/gateway/test_config.py— newTestHomeChannelPartialMapping: inheritance from the parent block, explicit-platform precedence,ValueErroron unresolvable shapes, and a boot-level check that an unresolvablehome_channelskips the platform block instead of raising.How to Test
1. Repro on unpatched main (the exact YAML the two
config setcommands from the issue write):GatewayConfig.from_dictonplatforms.telegram.home_channel = {chat_id: '123456789', name: Home}. Observed result:KeyError: 'platform'atHomeChannel.from_dictingateway/config.py.2. Same input with this patch: Observed result: the config loads and
platforms[TELEGRAM].home_channelisHomeChannel(platform=TELEGRAM, chat_id='123456789', name='Home')— platform inherited from the parent block.3. A healthy config (full
home_channelwith explicitplatform) loads unchanged; theto_dict/from_dictround-trip is covered by the existingTestHomeChannelRoundtripand still passes.4.
pytest tests/gateway/test_config.py tests/gateway/test_config_env_bridge_authority.py tests/gateway/test_slash_config_writes_routed_profile.py -q→ Observed result: 107 passed.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passpython scripts/checkpasses (the blocking lint and code-health checks CI runs)Documentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Before (unpatched
upstream/main):After (this patch):