fix(gateway): treat home_channel: null as absent in PlatformConfig.from_dict#22520
Closed
wesleysimplicio wants to merge 1 commit into
Closed
fix(gateway): treat home_channel: null as absent in PlatformConfig.from_dict#22520wesleysimplicio wants to merge 1 commit into
wesleysimplicio wants to merge 1 commit into
Conversation
…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
Contributor
There was a problem hiding this comment.
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 readhome_channelvia.get()and only parse when present. - Add regression tests covering
home_channel: nullandhome_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.
| if "home_channel" in data: | ||
| home_channel = HomeChannel.from_dict(data["home_channel"]) | ||
| raw_home_channel = data.get("home_channel") | ||
| if raw_home_channel: |
Collaborator
Contributor
Author
|
Closing in favor of #13791 per @alt-glitch's note — same home_channel: null guard for PlatformConfig.from_dict(). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PlatformConfig.from_dict()checked only whetherhome_channelwas a key in the platform dict, then passed the value straight intoHomeChannel.from_dict(). YAMLhome_channel: null— a common way to clear an inherited optional section — crashed withTypeError: 'NoneType' object is not subscriptable, breakingload_gateway_config()for otherwise valid configs.Root cause
Presence-only check ignored explicit
Nonevalues: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
TestPlatformConfigRoundtripgains:test_from_dict_treats_explicit_null_home_channel_as_absenttest_from_dict_treats_empty_home_channel_dict_as_absentStash-verify confirmed
test_from_dict_treats_explicit_null_home_channel_as_absentflips red without the fix (with the originalTypeErrorfromHomeChannel.from_dict).Closes #13708