hermes - 💡(How to fix) Fix [Bug]: DISCORD_ALLOWED_ROLES ignored by gateway _is_user_authorized — role-authorized users get 'Unauthorized user' rejection

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…

DISCORD_ALLOWED_ROLES is checked in the Discord adapter (_is_user_allowed, adapter.py:2235) but not in the gateway-level _is_user_authorized (run.py:6438). This means users authorized via role pass the adapter gate but are then rejected by the gateway, producing:

gateway.run: Unauthorized user: <user_id> (<username>) on discord

Root Cause

DISCORD_ALLOWED_ROLES is checked in the Discord adapter (_is_user_allowed, adapter.py:2235) but not in the gateway-level _is_user_authorized (run.py:6438). This means users authorized via role pass the adapter gate but are then rejected by the gateway, producing:

gateway.run: Unauthorized user: <user_id> (<username>) on discord

Fix Action

Workaround

Add user ID explicitly to DISCORD_ALLOWED_USERS.

Code Example

gateway.run: Unauthorized user: <user_id> (<username>) on discord
RAW_BUFFERClick to expand / collapse

Description

DISCORD_ALLOWED_ROLES is checked in the Discord adapter (_is_user_allowed, adapter.py:2235) but not in the gateway-level _is_user_authorized (run.py:6438). This means users authorized via role pass the adapter gate but are then rejected by the gateway, producing:

gateway.run: Unauthorized user: <user_id> (<username>) on discord

Two-layer auth mismatch

LayerFunctionChecks roles?
Discord adapter_is_user_allowed (adapter.py:2235)✅ Yes
Gateway_is_user_authorized (run.py:6438)❌ No

_is_user_authorized only reads DISCORD_ALLOWED_USERS via platform_env_map. DISCORD_ALLOWED_ROLES is never consulted at the gateway layer.

Steps to reproduce

  1. Set DISCORD_ALLOWED_ROLES=<role_id> (no DISCORD_ALLOWED_USERS set)
  2. Send a Discord message as a user with that role
  3. Observe Unauthorized user warning in logs despite role match

Workaround

Add user ID explicitly to DISCORD_ALLOWED_USERS.

Proposed fix

Add role_authorized: bool = False field to SessionSource. Discord adapter sets it True when _is_user_allowed passes via role (not user ID). Gateway's _is_user_authorized checks source.role_authorized as an additional allow condition.

This keeps the role resolution logic in the adapter (where guild/member context exists) while letting the gateway trust the adapter's decision.

Related

  • plugins/platforms/discord/adapter.py:678DISCORD_ALLOWED_ROLES parsing
  • plugins/platforms/discord/adapter.py:2235_is_user_allowed (checks roles)
  • gateway/run.py:6438_is_user_authorized (does not check roles)

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