hermes - 💡(How to fix) Fix discord.allowed_channels config.yaml field is non-functional — only DISCORD_ALLOWED_CHANNELS env var is read [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The discord.allowed_channels field in config.yaml is documented as load-bearing but never read by the source code. Operators editing this field believe they're whitelisting Discord channels when in fact they aren't — all channels remain allowed unless the DISCORD_ALLOWED_CHANNELS environment variable is set.

Root Cause

The discord client reads the channel whitelist from os.environ['DISCORD_ALLOWED_CHANNELS'] only (around gateway/platforms/discord.py:4077 in current main):

allowed_channels_raw = os.getenv("DISCORD_ALLOWED_CHANNELS", "")
if allowed_channels_raw:
    allowed_channels = {ch.strip() for ch in allowed_channels_raw.split(",") if ch.strip()}
    if "*" not in allowed_channels and not (channel_ids & allowed_channels):
        logger.debug("[%s] Ignoring message in non-allowed channel: %s", self.name, channel_ids)
        return

The YAML config is loaded but the allowed_channels key is never accessed. Documentation comment at discord.py:4048 describes it as a config option, which is inconsistent with the actual behavior.

By comparison, free_response_channels (line 3538) IS read from config.yaml via self.config.extra.get("free_response_channels") with env-var fallback — so the inconsistency is internal to the same module.

Fix Action

Fixed

Code Example

allowed_channels_raw = os.getenv("DISCORD_ALLOWED_CHANNELS", "")
if allowed_channels_raw:
    allowed_channels = {ch.strip() for ch in allowed_channels_raw.split(",") if ch.strip()}
    if "*" not in allowed_channels and not (channel_ids & allowed_channels):
        logger.debug("[%s] Ignoring message in non-allowed channel: %s", self.name, channel_ids)
        return
RAW_BUFFERClick to expand / collapse

Summary

The discord.allowed_channels field in config.yaml is documented as load-bearing but never read by the source code. Operators editing this field believe they're whitelisting Discord channels when in fact they aren't — all channels remain allowed unless the DISCORD_ALLOWED_CHANNELS environment variable is set.

Repro

  1. Set discord.allowed_channels: <channel_id> in config.yaml
  2. Leave DISCORD_ALLOWED_CHANNELS env var unset
  3. Restart Hermes daemon
  4. Observed: Hermes responds in ALL channels, not just the whitelisted one
  5. Expected: Hermes responds only in the whitelisted channel(s)

Root cause

The discord client reads the channel whitelist from os.environ['DISCORD_ALLOWED_CHANNELS'] only (around gateway/platforms/discord.py:4077 in current main):

allowed_channels_raw = os.getenv("DISCORD_ALLOWED_CHANNELS", "")
if allowed_channels_raw:
    allowed_channels = {ch.strip() for ch in allowed_channels_raw.split(",") if ch.strip()}
    if "*" not in allowed_channels and not (channel_ids & allowed_channels):
        logger.debug("[%s] Ignoring message in non-allowed channel: %s", self.name, channel_ids)
        return

The YAML config is loaded but the allowed_channels key is never accessed. Documentation comment at discord.py:4048 describes it as a config option, which is inconsistent with the actual behavior.

By comparison, free_response_channels (line 3538) IS read from config.yaml via self.config.extra.get("free_response_channels") with env-var fallback — so the inconsistency is internal to the same module.

Suggested fix

Read config.discord.allowed_channels as fallback when env var is unset, mirroring the pattern already used by _discord_free_response_channels at line 3531-3552. Or, alternately, remove the YAML field from the documentation comment + emit a deprecation warning if the YAML field is set without the env var.

Impact

  • Low for single-operator setups using DISCORD_ALLOWED_USERS (user-level gating sufficient)
  • High for multi-user setups expecting channel-level isolation — they believe they have it, they don't

Discovered during a Discord channel restructure where the operator updated config.yaml and expected Hermes to honor it, observed via a smoke test that messages were still being processed from channels not in the YAML list.

Environment

  • Hermes version: 0.13.0
  • Python: Python 3.11.15
  • OS: macOS Darwin

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING