Skip to content

Discord: 401 Unauthorized on send (read works) #79445

Closed as not planned
Closed as not planned

Description

@TStokes06

Bug Description

OpenClaw Discord bot connects successfully, can READ messages, but cannot SEND messages - returns 401 Unauthorized. Direct REST API calls with the same token work fine.

Environment

  • OpenClaw 2026.5.6/2026.5.7
  • Discord bot token valid (REST API works)
  • Bot is in server, online, Gateway shows 'connected'
  • Intents enabled: Message Content, Server Members, Presence

Config

{
  "channels": {
    "discord": {
      "enabled": true,
      "token": "MTUw... (valid token)"
    }
  }
}

What Works

  • message(action=read) ✅
  • Direct REST API POST /channels/{id}/messages ✅
  • Gateway connects, bot shows online in Discord ✅

What Doesn't Work

  • message(action=send) returns 401 Unauthorized ❌
  • CLI openclaw message send also fails ❌

Tested

  • Various target formats: to, channelId, guildId+channelId
  • With/without groupPolicy, guilds allowlist
  • With/without applicationId
  • Different intents config
  • Explicit account config
  • Minimal config

Discord Permissions

  • Bot has Administrator role (permission 8)
  • Channel has no overwrites (inherits from @everyone)
  • Guild @everyone permissions: 2248473465835073

Additional Notes

  • Bot ID: 1502285113214632170
  • This is a fresh bot created today
  • REST API test confirms token is valid
  • Read works but send doesn't - seems like outbound HTTP construction issue

Activity

  1. clawsweeper commented on May 8, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 28, 2026, 9:32 PM ET / 01:32 UTC.

    Summary
    Keep open: this remains a concrete Discord outbound send/auth report, current main still sends through the expected Discord bot REST path, and neither duplicate search nor recent main history shows a merged same-root fix or live current-main proof that the 401 is gone.

    Reproducibility: no. The issue body gives a concrete shipped-version setup and the source path for Discord send is clear, but this read-only review did not run a live Discord send against current main.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    Maintainer-controlled Discord credentials and a redacted live response capture are needed before automation can safely target a fix.

    Review details

    Best possible solution:

    Capture a live current-main Discord send with redacted outbound response details, then fix only the narrow token/account/request path if the 401 still reproduces.

    Do we have a high-confidence way to reproduce the issue?

    No. The issue body gives a concrete shipped-version setup and the source path for Discord send is clear, but this read-only review did not run a live Discord send against current main.

    Is this the best way to solve the issue?

    Unclear. Current main constructs Bot authorization and posts to the expected Discord channel-message route, so the best fix cannot be chosen until maintainers capture the live current-main response and selected account/token path.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No live maintainer Discord bot/server credential was exercised, so this review cannot prove the reported 401 is fixed or unreproducible on current main.
    • Current source shows the expected Bot authorization and channel-message route, so a speculative source-only fix could chase the wrong layer such as runtime config snapshot selection, SecretRef/account choice, proxy behavior, or Discord-side token state.

    Codex review notes: model internal, reasoning high; reviewed against 4b8a0a8ecf83.

    Label changes

    Label changes:

    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.
    • remove clawsweeper:needs-info: Current issue advisory state no longer selects this label.
    • remove issue-rating: 🦐 gold shrimp: Current issue advisory state no longer selects this label.

    Label justifications:

    • P2: A reported Discord send failure blocks outbound messages for one stable channel but is not shown as a core-wide outage.
    • impact:message-loss: The issue is specifically about outbound Discord messages failing to send.
    • impact:auth-provider: The observable failure is a 401 Unauthorized response on a configured Discord bot token path.
    • maturity:stable: The affected Discord surface is scored M4 Stable in qa/maturity-scores.yaml.
    Evidence reviewed

    Acceptance criteria:

    • Run a live current-main Discord send with maintainer-controlled credentials, for example openclaw message send --channel discord --target channel:<redacted> --message <redacted> --json --verbose, and capture status/body without secrets.
    • If the 401 reproduces, verify selected account id, token source/status, proxy path, and final Authorization scheme without printing the token.
    • After any source fix, run focused Discord send/token/REST coverage such as node scripts/run-vitest.mjs extensions/discord/src/send.sends-basic-channel-messages.test.ts extensions/discord/src/token.test.ts extensions/discord/src/client.test.ts extensions/discord/src/internal/rest.test.ts plus the live send proof.

    What I checked:

    • Repository policy applied: Root AGENTS.md and scoped channel/extension/SDK AGENTS.md files were read; the applicable guidance treats channel delivery and auth/config paths as source- and live-proof-sensitive. (AGENTS.md:1, 4b8a0a8ecf83)
    • Live issue state: GitHub shows this issue remains open with P2, needs-info, message-loss, auth-provider, and maturity:stable labels; the body reports Discord read and direct REST send work while OpenClaw send returns 401.
    • Current send path: Current main resolves the Discord account/client, parses the recipient, resolves a channel id, then sends through sendDiscordText or sendDiscordMedia; there is no evidence here that the outbound path bypasses Discord REST auth. (extensions/discord/src/send.outbound.ts:149, 4b8a0a8ecf83)
    • REST Authorization construction: RequestClient builds Discord REST requests with the configured API base/version and sets Authorization to the token header, defaulting to Bot, before throwing DiscordError on non-OK responses. (extensions/discord/src/internal/rest.ts:275, 4b8a0a8ecf83)
    • Discord channel-message route: Both read and create message helpers use Discord's Routes.channelMessages(channelId), matching the reporter's direct POST endpoint shape for sends. (extensions/discord/src/internal/api.messages.ts:22, 4b8a0a8ecf83)
    • Token resolution coverage: Existing tests cover config-vs-env precedence and runtime snapshot SecretRef token resolution, but they are mocked/unit coverage and do not prove this live Discord 401 is fixed. (extensions/discord/src/token.test.ts:16, 4b8a0a8ecf83)

    Likely related people:

    • Peter Steinberger: Git history shows multiple Discord outbound send refactors near target parsing and result mapping, including commits that still define the current send path shape. (role: feature-history contributor; confidence: medium; commits: 9832559f4505, 90f33ed5dafa, 9c8297408299; files: extensions/discord/src/send.outbound.ts, extensions/discord/src/send.shared.ts)
    • vincentkoc: Auth/send-adjacent PR metadata shows vincentkoc authored and merged the Discord/Slack message tool send fix and merged the recent Discord REST gzip fix. (role: recent area contributor and merger; confidence: medium; commits: 29ad211e7647, 8f31b3218f9d; files: extensions/discord/src/outbound-adapter.ts, extensions/discord/src/internal/rest.ts)
    • joshavant: PR metadata ties joshavant to the prior fix threading runtime config through Discord/Telegram send paths, directly adjacent to account/token resolution for outbound sends. (role: auth/runtime config fix author; confidence: medium; commits: 0687e0476021, 7148999308c4; files: extensions/discord/src/token.ts, extensions/discord/src/client.ts, extensions/discord/src/send.outbound.ts)
    • jbetala7: PR metadata shows jbetala7 authored the recent Discord REST gzip response parsing change in the same RequestClient area that constructs auth headers and raises REST errors. (role: recent REST contributor; confidence: medium; commits: 8f31b3218f9d, 11c2b533eb0f; files: extensions/discord/src/internal/rest.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. barnacle-openclaw commented on May 31, 2026

    @barnacle-openclaw

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  3. added
    P2Normal backlog priority with limited blast radius.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on May 31, 2026
  4. added
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jun 14, 2026
  5. added
    maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    and removed
    issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.
    clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.
    issue-rating: 🦐 gold shrimpDecent issue quality, but reproduction details are still incomplete.
    on Jun 28, 2026
  6. openclaw-barnacle commented on Jul 13, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  7. openclaw-barnacle commented on Jul 20, 2026

    @openclaw-barnacle

    Closing due to inactivity.
    If this is still an issue, please retry on the latest OpenClaw release and share updated details.
    If you are absolutely sure it still happens on the latest release, open a new issue with fresh steps to reproduce.

  8. locked as resolved and limited conversation to collaborators on Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions