Skip to content

fix(gateway): PlatformConfig.from_dict now maps top-level platform keys into extra#10208

Open
rainow wants to merge 1 commit into
NousResearch:mainfrom
rainow:main
Open

fix(gateway): PlatformConfig.from_dict now maps top-level platform keys into extra#10208
rainow wants to merge 1 commit into
NousResearch:mainfrom
rainow:main

Conversation

@rainow

@rainow rainow commented Apr 15, 2026

Copy link
Copy Markdown

Add handling for extra fields in from_dict method to solve platforms.webhook.port doesn't work problem

What does this PR do?

Fix a silent config drop bug where top-level keys written under a platform
block in config.yaml (e.g. platforms.webhook.port) were silently ignored
instead of being forwarded to the adapter.

Problem

PlatformConfig.from_dict() only recognised a fixed set of known fields
(enabled, token, api_key, home_channel, reply_to_mode, extra).
Any other key — such as port, host, secret, or routes — was silently
dropped when the YAML block was parsed.

Platform adapters (e.g. WebhookAdapter) read their settings exclusively from
config.extra:

# gateway/platforms/webhook.py
self._port = int(config.extra.get("port", DEFAULT_PORT))

So a user writing the natural top-level form:

# config.yaml
platforms:
  webhook:
    enabled: true
    port: 9000        # ← silently dropped, DEFAULT_PORT (8644) used instead

…would never see the port change take effect. The only working form was the
nested extra: block, which is not obvious from the documentation or the
error log (no warning is emitted):

platforms:
  webhook:
    enabled: true
    extra:
      port: 9000      # ← works, but not user-friendly

The same silent drop affected every other platform adapter that reads
settings from config.extra (e.g. api_server.host, api_server.key,
webhook secret, routes, etc.).

Related Issue

#10206

Fixes #

Type of Change

  • [ ✅] 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

In PlatformConfig.from_dict() (gateway/config.py), after extracting the
known fields, iterate over the remaining keys and merge them into extra via
setdefault (so an explicit extra: sub-dict always takes precedence):

_KNOWN_KEYS = {"enabled", "token", "api_key", "home_channel", "reply_to_mode", "extra"}
extra = dict(data.get("extra", {}))
for key, value in data.items():
    if key not in _KNOWN_KEYS:
        extra.setdefault(key, value)

This means both config styles now work identically:

# Style 1 — top-level (now works)
platforms:
  webhook:
    enabled: true
    port: 9000

# Style 2 — nested extra (always worked, still takes precedence)
platforms:
  webhook:
    enabled: true
    extra:
      port: 9000

How to Test

# Start gateway with top-level port in config.yaml:
#   platforms:
#     webhook:
#       enabled: true
#       port: 9100
# Verify the server binds on 9100 instead of the default 8644.
python -m pytest tests/gateway/ -q

Add handling for extra fields in from_dict method
@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 platform/webhook Webhook / API server labels Apr 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #10453 — same root cause: PlatformConfig.from_dict() drops unknown top-level platform keys instead of folding into extra dict. Please coordinate or close one.

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 platform/webhook Webhook / API server type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants