Skip to content

fix(gateway/config): merge top-level platform keys into extra (#20501)#20506

Open
Beandon13 wants to merge 1 commit into
NousResearch:mainfrom
Beandon13:fix/hermes-20501-platform-toplevel-keys
Open

fix(gateway/config): merge top-level platform keys into extra (#20501)#20506
Beandon13 wants to merge 1 commit into
NousResearch:mainfrom
Beandon13:fix/hermes-20501-platform-toplevel-keys

Conversation

@Beandon13

Copy link
Copy Markdown
Contributor

Summary

Fixes #20501platforms.api_server config values (port, host, key, cors_origins) are silently ignored when written at the natural top level instead of nested under extra.

Root cause

PlatformConfig.from_dict() in gateway/config.py only read platform-specific values from data.get("extra", {}). But hermes config set platforms.api_server.port 8643 writes the value at platforms.api_server.port (top level of the platform block, which is the natural and documented YAML shape and matches the error message in api_server.py:3112). The result: gateway falls back to default 8642 with no warning, no error, no log line — extremely hard to debug.

Fix

In PlatformConfig.from_dict(), merge any top-level keys that aren't dedicated PlatformConfig fields (enabled, token, api_key, home_channel, reply_to_mode, extra) into the extra dict. Explicit extra entries still win on key collision so the to_dictfrom_dict roundtrip remains stable for existing configs.

This is a minimal, additive change — existing nested-under-extra configs keep working unchanged; the new behavior only kicks in for top-level keys that were previously dropped on the floor.

Test plan

  • New regression test: top-level port/host/key/cors_origins now reach extra
  • New regression test: explicit extra wins over a stale top-level key (roundtrip stability)
  • New regression test: reserved keys (token, api_key, reply_to_mode) still consumed as fields, not pushed into extra
  • All 43 tests in tests/gateway/test_config.py pass

Affected adapters

Any platform whose adapter reads config.extra.get(...) benefits. The reported issue is api_server (port/host/key/cors_origins/model_name) but the same pattern is used across other platform adapters, so they all become more forgiving of natural top-level config layout.

…search#20501)

PlatformConfig.from_dict() previously read platform-specific settings only
from the explicit ``extra`` mapping. ``hermes config set platforms.api_server.port
8643`` writes the value at ``platforms.api_server.port`` (not nested under
``extra``), so the gateway silently ignored it and bound to the default
8642 with no warning.

Top-level keys other than the dedicated PlatformConfig fields (enabled,
token, api_key, home_channel, reply_to_mode, extra) are now merged into
``extra`` so adapters that read ``config.extra.get(...)`` see what users
actually configured. Explicit ``extra`` entries still win on conflict so
the to_dict→from_dict roundtrip remains stable.

Adds three regression tests covering the natural top-level layout, the
extra-wins precedence, and the reserved-keys carve-out.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels May 6, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #10453 (and related to #10208). Both fix the same underlying bug: PlatformConfig.from_dict() drops top-level platform keys instead of folding them into extra. PR #10453 has been open since April 15 targeting the same code path (fixes #10206); this PR targets #20501 which is the same bug for api_server specifically.

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 duplicate This issue or pull request already exists 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.

platforms.api_server config values (port, host, key) silently ignored when not nested under 'extra'

2 participants