Skip to content

fix(gateway): treat home_channel: null as absent in PlatformConfig.from_dict#22520

Closed
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:fix/agente-b-home-channel-null-safe
Closed

fix(gateway): treat home_channel: null as absent in PlatformConfig.from_dict#22520
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:fix/agente-b-home-channel-null-safe

Conversation

@wesleysimplicio

Copy link
Copy Markdown
Contributor

Problem

PlatformConfig.from_dict() checked only whether home_channel was a key in the platform dict, then passed the value straight into HomeChannel.from_dict(). YAML home_channel: null — a common way to clear an inherited optional section — crashed with TypeError: 'NoneType' object is not subscriptable, breaking load_gateway_config() for otherwise valid configs.

PlatformConfig.from_dict({"enabled": True, "home_channel": None})
# TypeError: 'NoneType' object is not subscriptable

Root cause

Presence-only check ignored explicit None values:

if "home_channel" in data:
    home_channel = HomeChannel.from_dict(data["home_channel"])

Fix

Read with .get() and only descend when the value is truthy. Empty dict is also treated as absent for consistency with the previous absence-equivalence semantics.

Tests

TestPlatformConfigRoundtrip gains:

  • test_from_dict_treats_explicit_null_home_channel_as_absent
  • test_from_dict_treats_empty_home_channel_dict_as_absent

Stash-verify confirmed test_from_dict_treats_explicit_null_home_channel_as_absent flips red without the fix (with the original TypeError from HomeChannel.from_dict).

Closes #13708

…om_dict

Problem: `PlatformConfig.from_dict()` checked only whether `home_channel`
was a key in the platform dict, then passed the value straight into
`HomeChannel.from_dict()`. YAML `home_channel: null` (a common way to
clear an inherited optional section) crashed with
`TypeError: 'NoneType' object is not subscriptable`, breaking
`load_gateway_config()` for otherwise valid configs.

Root cause: presence-only check ignores explicit None values.

Fix: read the value with `.get()` and only call `HomeChannel.from_dict`
when the value is truthy. Empty dict is also treated as absent for
consistency with the previous YAML semantics.

Tests: TestPlatformConfigRoundtrip gains coverage for explicit
`home_channel: None` and `{}` dict.

Closes NousResearch#13708
Copilot AI review requested due to automatic review settings May 9, 2026 11:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes gateway config loading when home_channel is explicitly set to YAML null, ensuring PlatformConfig.from_dict() treats it as “absent” instead of passing None into HomeChannel.from_dict() and crashing.

Changes:

  • Update PlatformConfig.from_dict() to read home_channel via .get() and only parse when present.
  • Add regression tests covering home_channel: null and home_channel: {} cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
gateway/config.py Adjusts PlatformConfig.from_dict() handling of home_channel to avoid crashing on explicit null/empty configs.
tests/gateway/test_config.py Adds regression tests to ensure explicit null/empty home_channel is treated as absent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gateway/config.py
if "home_channel" in data:
home_channel = HomeChannel.from_dict(data["home_channel"])
raw_home_channel = data.get("home_channel")
if raw_home_channel:
@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 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #13791 — same home_channel: null guard fix for PlatformConfig.from_dict(). Also see closed #13721 which was the original fix attempt.

@wesleysimplicio

Copy link
Copy Markdown
Contributor Author

Closing in favor of #13791 per @alt-glitch's note — same home_channel: null guard for PlatformConfig.from_dict().

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.

Bug: gateway config loading crashes on explicit home_channel: null

3 participants