Skip to content

fix(gateway): tolerate null nested platform config entries#13319

Closed
ghost wants to merge 1 commit into
mainfrom
unknown repository
Closed

fix(gateway): tolerate null nested platform config entries#13319
ghost wants to merge 1 commit into
mainfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Apr 21, 2026

Copy link
Copy Markdown

Summary

GatewayConfig.from_dict() and PlatformConfig.from_dict() were assuming that nested fields are always mappings in some legacy or manually edited config inputs. As a result, valid YAML/JSON values such as home_channel: null, extra: null, or platforms.telegram: null could cause exceptions during gateway startup and lead to config loading failures.

This PR makes config deserialization more robust by safely normalizing these fields.

Problem

The following types of config values could cause crashes:

platforms:
telegram: null

or

platforms:
telegram:
enabled: true
home_channel: null
extra: null

In the current flow:

  • PlatformConfig.from_dict() directly called HomeChannel.from_dict(...) for home_channel
  • The extra field was assumed to be a dict
  • GatewayConfig.from_dict() assumed every entry under platforms was a dict

This could produce AttributeError or type-related crashes when encountering values like None.

Fix

A minimal and merge-friendly fix has been applied:

  • PlatformConfig.from_dict() now falls back to an empty config if input is not a dict
  • home_channel is only deserialized if it is a dict
  • extra is normalized to {} if it is not a dict
  • GatewayConfig.from_dict() falls back to an empty config if top-level input is not a dict
  • platforms field is treated as an empty mapping if it is not a dict

This change does not alter behavior for valid configs; it only ensures safe fallback instead of crashes for malformed / missing / null nested values.

Tests

Two regression tests were added:

  • PlatformConfig.from_dict() uses safe fallback when home_channel=None and extra=None
  • GatewayConfig.from_dict() continues with default PlatformConfig() when platforms={"telegram": None}

Verification

The following flows were manually verified:

PlatformConfig.from_dict({"enabled": True, "home_channel": None, "extra": None})
GatewayConfig.from_dict({"platforms": {"telegram": None}})

In both cases, expected default objects are now returned instead of exceptions.

Why this matters

This small fix:

  • makes gateway startup more resilient
  • prevents breakage in legacy gateway.json / manually edited config.yaml variations
  • eliminates a real crash class in the config loading path without introducing behavioral changes

@ghost ghost closed this Apr 21, 2026
@ghost ghost reopened this Apr 21, 2026
Repository owner closed this by deleting the head repository Apr 21, 2026
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels Apr 21, 2026
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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants