Summary
PlatformConfig.from_dict() crashes when home_channel is explicitly present but set to null. That makes load_gateway_config() fail on otherwise reasonable YAML like:
platforms:
telegram:
enabled: true
home_channel: null
Affected code
gateway/config.py:173-185
- especially
gateway/config.py:175-177
Why this is a bug
YAML null is a common way to clear an optional nested config section. The code checks only whether the key exists, then blindly passes None into HomeChannel.from_dict(), which subscripts it like a dict.
Minimal reproduction
from gateway.config import PlatformConfig
PlatformConfig.from_dict({"enabled": True, "home_channel": None})
Actual exception:
TypeError: 'NoneType' object is not subscriptable
End-to-end repro:
import os, pathlib, tempfile, textwrap
from gateway.config import load_gateway_config
with tempfile.TemporaryDirectory() as td:
os.environ["HERMES_HOME"] = td
pathlib.Path(td, "config.yaml").write_text(textwrap.dedent('''\
platforms:
telegram:
enabled: true
home_channel: null
'''))
load_gateway_config()
Expected behavior
home_channel: null should be treated the same as an absent home channel.
Actual behavior
- Config loading crashes with
TypeError: 'NoneType' object is not subscriptable.
Suggested investigation
Guard PlatformConfig.from_dict() with if data.get("home_channel") is not None: before calling HomeChannel.from_dict(), and add a regression test for explicit null home channels in YAML.
Summary
PlatformConfig.from_dict()crashes whenhome_channelis explicitly present but set tonull. That makesload_gateway_config()fail on otherwise reasonable YAML like:Affected code
gateway/config.py:173-185gateway/config.py:175-177Why this is a bug
YAML
nullis a common way to clear an optional nested config section. The code checks only whether the key exists, then blindly passesNoneintoHomeChannel.from_dict(), which subscripts it like a dict.Minimal reproduction
Actual exception:
End-to-end repro:
Expected behavior
home_channel: nullshould be treated the same as an absent home channel.Actual behavior
TypeError: 'NoneType' object is not subscriptable.Suggested investigation
Guard
PlatformConfig.from_dict()withif data.get("home_channel") is not None:before callingHomeChannel.from_dict(), and add a regression test for explicitnullhome channels in YAML.