Skip to content

Gateway config-backed Home Assistant / Mattermost / Signal adapters are blocked by env-only requirement checks #13827

@NewTurn2017

Description

@NewTurn2017

Summary

GatewayRunner._create_adapter() rejects config-backed Home Assistant, Mattermost, and Signal adapters because its preflight checks only look at environment variables. Each adapter constructor already accepts PlatformConfig values, but the gateway never instantiates them unless duplicate env vars are also present.

Affected code

  • gateway/run.py:2111-2181
  • gateway/platforms/homeassistant.py:42-48
  • gateway/platforms/homeassistant.py:75-80
  • gateway/platforms/mattermost.py:53-68
  • gateway/platforms/mattermost.py:77-81
  • gateway/platforms/signal.py:130-149

Why this is a bug

The runtime contract is inconsistent:

  • HomeAssistantAdapter(config) reads config.token and config.extra["url"].
  • MattermostAdapter(config) reads config.token and config.extra["url"].
  • SignalAdapter(config) reads config.extra["http_url"] and config.extra["account"].

But GatewayRunner._create_adapter() blocks all three adapters behind check_*_requirements() helpers that only consult env vars (HASS_TOKEN, MATTERMOST_*, SIGNAL_*).

So a valid config.yaml setup can be loaded into PlatformConfig and still fail to start in the normal gateway path.

Minimal reproduction

Run from the repo root with env vars unset:

import os
from types import SimpleNamespace
from gateway.run import GatewayRunner
from gateway.config import PlatformConfig, Platform

for key in [
    'HASS_TOKEN', 'HASS_URL',
    'MATTERMOST_TOKEN', 'MATTERMOST_URL',
    'SIGNAL_HTTP_URL', 'SIGNAL_ACCOUNT',
]:
    os.environ.pop(key, None)

fake_self = SimpleNamespace(
    config=SimpleNamespace(group_sessions_per_user=False, thread_sessions_per_user=False)
)

cases = [
    (Platform.HOMEASSISTANT, PlatformConfig(enabled=True, token='tok', extra={'url': 'http://ha.local'})),
    (Platform.MATTERMOST, PlatformConfig(enabled=True, token='tok', extra={'url': 'https://mm.example.com'})),
    (Platform.SIGNAL, PlatformConfig(enabled=True, extra={'http_url': 'http://127.0.0.1:8080', 'account': '+15551234567'})),
]

for platform, cfg in cases:
    print(platform.value, GatewayRunner._create_adapter(fake_self, platform, cfg))

Observed output:

HomeAssistant: aiohttp not installed or HASS_TOKEN not set
Mattermost: MATTERMOST_TOKEN or MATTERMOST_URL not set, or aiohttp missing
Signal: SIGNAL_HTTP_URL or SIGNAL_ACCOUNT not configured
homeassistant None
mattermost None
signal None

Even though constructing the adapters directly with the same PlatformConfig works.

Expected behavior

If the required values are present in PlatformConfig, _create_adapter() should instantiate the adapter without requiring duplicate env vars.

Actual behavior

_create_adapter() returns None for config-backed Home Assistant / Mattermost / Signal setups unless equivalent env vars are also exported.

Suggested investigation

  • Make check_ha_requirements(), check_mattermost_requirements(), and check_signal_requirements() accept a PlatformConfig (or remove the env-only gate and let the adapter validate after construction).
  • Add a regression test that exercises _create_adapter() with config-only platform credentials.

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