fix(gateway): accept explicit null home_channel in PlatformConfig.from_dict#13721
Closed
hclsys wants to merge 1 commit into
Closed
fix(gateway): accept explicit null home_channel in PlatformConfig.from_dict#13721hclsys wants to merge 1 commit into
hclsys wants to merge 1 commit into
Conversation
…m_dict (NousResearch#13708) YAML 'home_channel: null' is a common way to clear an optional nested section. Current code only checks key-presence and passes None into HomeChannel.from_dict(), which subscripts it and crashes with TypeError: 'NoneType' object is not subscriptable. Treat explicit null the same as absent by switching the guard to data.get('home_channel') is not None. Add a regression test covering the explicit-null YAML shape.
Collaborator
|
Related to #13319 (closed) which addressed null-safe deserialization in the same config area — this covers the specific home_channel: null case. |
1 similar comment
Collaborator
|
Related to #13319 (closed) which addressed null-safe deserialization in the same config area — this covers the specific home_channel: null case. |
Author
|
Closing — not pursuing further. Thanks for the triage. |
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.
Summary
Fixes #13708.
PlatformConfig.from_dict()crashes on the common YAML pattern of explicitly clearing an optional nested section withnull:```yaml
platforms:
telegram:
enabled: true
home_channel: null
```
Current code only checks for key-presence (`if "home_channel" in data`) and then unconditionally passes the value into `HomeChannel.from_dict()`, which subscripts it like a dict and raises `TypeError: 'NoneType' object is not subscriptable`.
Fix
One-line guard change: switch to `data.get("home_channel") is not None` so explicit `null` is treated the same as absent.
Test
Added a regression test covering the explicit-null YAML shape. All 28 tests in `tests/gateway/test_config.py` pass locally.
Scope
Pure bug-fix, purely additive semantics. No behavior change for existing callers (a dict home_channel still round-trips identically; missing home_channel still yields `None`). I audited all production and test callers of `PlatformConfig.from_dict()` — only one production call site in the same file at L384 (`load_gateway_config`) and 5 test sites; none pass `None` today so existing contract is preserved.
Closes #13708.