Skip to content

fix(gateway): bridge shared-key loop to nested platform config blocks - #35866

Closed
AhmetArif0 wants to merge 1 commit into
NousResearch:mainfrom
AhmetArif0:fix/shared-key-loop-nested-platform-fallback
Closed

fix(gateway): bridge shared-key loop to nested platform config blocks#35866
AhmetArif0 wants to merge 1 commit into
NousResearch:mainfrom
AhmetArif0:fix/shared-key-loop-nested-platform-fallback

Conversation

@AhmetArif0

Copy link
Copy Markdown
Contributor

Summary

The shared-key bridging loop in load_gateway_config() — which copies allow_from, require_mention, free_response_channels, and ~20 other keys into PlatformConfig.extra — read only the top-level yaml platform block (yaml_cfg.get(plat.value)). When a user configured a platform solely under platforms: or gateway.platforms: without a top-level block, the loop silently skipped the platform and all bridged keys were dropped, making access control and mention settings ineffective for nested-only configs.

The apply_yaml_config_fn dispatch already received this same nested fallback in 44f3e51 to handle plugin platforms (Discord allow_from). The shared-key loop now mirrors it exactly.

Why enabled is excluded from the nested fallback: _merge_platform_map already merged enabled with the correct platforms.* > gateway.platforms.* precedence before the loop runs. Re-applying it from a single nested source would overwrite the correctly-merged value, which caused the existing test_top_level_platforms_override_nested_gateway_platforms test to fail in an earlier version of this fix.

Test plan

  • Two new regression tests: allow_from + require_mention configured under platforms.telegram and gateway.platforms.telegram (no top-level block) are correctly bridged into PlatformConfig.extra
  • All 54 existing tests/gateway/test_config.py tests pass, including the enabled precedence test
  • 2 files changed: gateway/config.py (+21 lines), tests/gateway/test_config.py (+62 lines)

The shared-key bridging loop (allow_from, require_mention,
free_response_channels, …) read only the top-level yaml platform block
(yaml_cfg.get(plat.value)).  When a user configured a platform solely
under ``platforms:`` or ``gateway.platforms:`` with no top-level block,
the loop skipped that platform entirely and all bridged keys were silently
dropped into PlatformConfig.extra — making allow_from, require_mention,
etc. ineffective for nested-only configs.

The apply_yaml_config_fn dispatch already received this same fallback in
44f3e51 to handle plugin adapters (e.g. Discord allow_from).  The
shared-key loop now mirrors it: if yaml_cfg.get(plat.value) is absent,
fall back to gateway.platforms.<name> then platforms.<name>.

The enabled field is deliberately excluded from the nested fallback
(guarded by _cfg_toplevel): _merge_platform_map already merged it with
the correct precedence, so re-applying it from a single nested source
would overwrite the correctly-merged value.

Two new regression tests assert that allow_from and require_mention
configured under platforms.telegram and gateway.platforms.telegram are
bridged into PlatformConfig.extra.  All 54 existing config tests pass.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels May 31, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Follow-up to merged #35329 which fixed nested platform config loading + Discord allow_from bridging. This PR extends the fix to the shared-key bridging loop (allow_from, require_mention, free_response_channels, etc.) which still read only the top-level yaml block. Related: #34565 (closed), #28245 (open).

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

✅ What's Good

  • Correct fix: The shared-key loop (_merge_platform_map) now falls back to nested platforms: / gateway.platforms: paths when a top-level platform block is absent. This mirrors the identical fix already applied to apply_yaml_config_fn (#44f3e51), ensuring consistency.
  • Good edge case handling: The _cfg_toplevel flag correctly distinguishes top-level from nested configs, allowing the enabled field to remain sourced only from top-level blocks (as _merge_platform_map already handles it with correct precedence for nested configs).
  • Clean tests: Two regression tests (platforms: and gateway.platforms: paths) with clear, descriptive docstrings that document the bug and the expected behavior.
  • Proper scope: 83 additions, 1 deletion — focused fix with good test coverage.

Summary

A well-scoped fix for a config parsing correctness bug. No issues found.


Reviewed by Hermes Agent

@teknium1

teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Merged via PR #38984. Your commit was cherry-picked onto current main with your authorship preserved in git log (4ae3c98). Thanks for catching the shared-key-loop parity gap — nested-only platforms: / gateway.platforms: policy keys (allow_from, dm_policy, require_mention, …) now bridge into PlatformConfig.extra correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants