Skip to content

Bug: gateway config loading crashes on explicit home_channel: null #13708

@NewTurn2017

Description

@NewTurn2017

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/configConfig system, migrations, profilescomp/gatewayGateway runner, session dispatch, deliverytype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions