Skip to content

[Bug] @openclaw/discord 2026.5.3-1 channel still skipped silently with env-backed SecretRef token (regression of #76371; fix #76449 missed dist/ sidecar layout) #77416

Closed

Description

@mogglemoss

Bug

@openclaw/discord@2026.5.3 (shipped as openclaw@2026.5.3-1 on npm) still fails to start the Discord channel when channels.discord.token is configured as an env-backed SecretRef, despite issue #76371 being closed by merged PR #76449 ("fix(secretrefs): resolve external channel contracts").

Failure mode shifted from the explicit crash on 2026.5.2 (unresolved SecretRef "env:default:DISCORD_BOT_TOKEN") to a silent skip: the plugin loads, no error is logged, but the Discord channel never starts and shows error: not configured in openclaw channels status.

Reproduction (clean)

  1. openclaw@2026.5.3-1 installed (npm view openclaw version → 2026.5.3-1); @openclaw/discord@2026.5.3 plugin installed at ~/.openclaw/npm/node_modules/@openclaw/discord/.
  2. ~/.openclaw/openclaw.json includes:
    {
      "secrets": { "providers": { "default": { "source": "env" } } },
      "channels": {
        "discord": {
          "enabled": true,
          "token": { "source": "env", "provider": "default", "id": "DISCORD_BOT_TOKEN" }
        }
      }
    }
  3. DISCORD_BOT_TOKEN is set in the gateway service's env (via ~/.openclaw/.env autoload).
  4. Restart the gateway: launchctl kickstart -k gui/$UID/ai.openclaw.gateway.

Expected (per #76449)

Discord channel starts. Log shows channels/discord :: [default] starting provider (@<bot>).

Actual

  • No starting provider log line. Plugin is loaded (counted in 9 plugins: ...; discord; ...) but channel never starts.
  • openclaw channels status shows: Discord default: enabled, configured, secret unavailable in this command path, stopped, disconnected, token:config (unavailable), health:not-running, error:not configured
  • openclaw status --deep channels table: Discord │ ON │ WARN │ configured token unavailable in this command path
  • Removing the channels.discord.token block (env-fallback only) → channel comes up immediately. So the trigger is the SecretRef config exactly as documented.

Root cause

PR #76449 added an external-plugin secret-contract-api loader at src/secrets/channel-contract-api.ts. Its path resolver, resolvePluginContractApiPath(rootDir), only checks <rootDir>/secret-contract-api.{js,mjs,cjs,ts,mts,cts} and <rootDir>/contract-api.{...}.

Real npm-published externalized channel plugins put compiled artifacts under <rootDir>/dist/ (per package.json openclaw.runtimeExtensions: ["./dist/index.js"]). For example, the actual sidecar in the installed Discord plugin lives at:

~/.openclaw/npm/node_modules/@openclaw/discord/dist/secret-contract-api.js

But the resolver only looks in:

~/.openclaw/npm/node_modules/@openclaw/discord/secret-contract-api.{js,mjs,cjs,ts,mts,cts}    (none of these exist)

Returns null → loadExternalChannelSecretContractFromRecord returns undefined → collectChannelConfigAssignments skips Discord → no SecretRef assignment queued → runtime snapshot keeps channels.discord.token as the unresolved SecretRef object.

Downstream: selectDiscordRuntimeConfig returns the snapshot (same SecretRef value), resolveDiscordToken calls resolveSecretInputString({ mode: "inspect" }) on the still-unresolved SecretRef → returns configured_unavailable → account.token is "", account.tokenStatus is configured_unavailable → discordPlugin.config.isConfigured(account) returns false (extensions/discord/src/shared.ts:152: Boolean(account.token?.trim())) → gateway sets lastError: "not configured" and never calls gateway.startAccount.

The existing PR #76449 test fixture (src/secrets/channel-contract-api.external.test.ts) writes a flat-layout sidecar at <rootDir>/secret-contract-api.cjs, which masks the bug because no real-world npm package layout was exercised.

Why the failure mode is silent

Result: error:not configured only surfaces if you explicitly query openclaw channels status.

Fix

Make resolvePluginContractApiPath also check <rootDir>/dist/ for compiled npm-published externalized channel plugins. PR submitting now.

Workaround

Remove channels.discord.token from openclaw.json and rely on the env-fallback inside the Discord plugin (process.env.DISCORD_BOT_TOKEN). This bypasses the SecretRef path entirely, which is documented as supported per extensions/discord/src/doctor.ts and docs/channels/discord.md.

Environment

  • OS: macOS 26.2 (arm64), Node 25.9.0
  • OpenClaw: 2026.5.3-1 (npm global, LaunchAgent-managed gateway)
  • Plugin: @openclaw/discord@2026.5.3 installed at ~/.openclaw/npm/node_modules/@openclaw/discord/
  • Build artifact verified on disk: dist/secret-contract-api.js exists, root-level secret-contract-api.* does not.

Disclosure

This bug report and the accompanying PR were drafted with AI assistance (Claude Code, model claude-opus-4-7) using interactive code review of the installed plugin source and the cloned openclaw/openclaw main branch. The author has independently verified the on-disk paths and the production behavior, and has tested the fix locally against src/secrets/channel-contract-api.external.test.ts.

Activity

  1. clawsweeper commented on May 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Summary
    Keep open: current main still searches external channel secret-contract sidecars only at the plugin root, while the Discord docs support the reported env-backed SecretRef token shape and an open linked PR targets this exact remaining gap.

    Reproducibility: yes. source inspection gives a high-confidence reproduction path: a plugin record whose contract file exists only at rootDir/dist/secret-contract-api.js will make loadExternalChannelSecretContractFromRecord return undefined on current main. I did not run the test fixture because this sweep is read-only.

    Next step
    An open PR with closing syntax already targets this issue, so a separate repair job would duplicate the active implementation path.

    Review details

    Best possible solution:

    Review and land or close the linked dist-sidecar PR, keeping the fix limited to external channel contract discovery and a dist-layout regression test.

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

    Yes, source inspection gives a high-confidence reproduction path: a plugin record whose contract file exists only at rootDir/dist/secret-contract-api.js will make loadExternalChannelSecretContractFromRecord return undefined on current main. I did not run the test fixture because this sweep is read-only.

    Is this the best way to solve the issue?

    Yes, the narrow maintainable fix is to make resolvePluginContractApiPath recognize compiled dist/ contract sidecars while preserving the existing boundary-file check and flat-layout compatibility.

    What I checked:

    Likely related people:

    • joshavant: PR fix(secretrefs): resolve external channel contracts #76449 added the external channel secret-contract loader and the current flat-layout test coverage that this report says missed published dist sidecars; the changelog credits that fix to @joshavant. (role: introduced behavior / likely follow-up owner; confidence: high; commits: 7ec0dbe0af57; files: src/secrets/channel-contract-api.ts, src/secrets/channel-contract-api.external.test.ts, CHANGELOG.md)
    • PrinceOfEgypt: The changelog credits v2026.5.2 upgrade fails: "Plugin install payload missing after update" for @openclaw/diffs #76426 for building package-local runtime dist files for publishable plugins including @openclaw/discord, which is the layout this loader now needs to recognize. (role: adjacent packaging owner; confidence: medium; files: CHANGELOG.md, extensions/discord/package.json, docs/plugins/sdk-entrypoints.md)
    • Peter Steinberger: Local history shows earlier channel contract public seam work by this author, which is adjacent to the contract-loading surface even though the specific root-only resolver came later. (role: adjacent channel contract maintainer; confidence: low; commits: f36354e401fe, fc3246d8fd86, 8d39fe5a765c; files: src/secrets/channel-contract-api.ts, src/secrets/channel-contract-api.external.test.ts)

    Remaining risk / open question:

    • No live Discord gateway reproduction was run during this read-only review; the decision relies on current-main source inspection plus the reporter's detailed production reproduction.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 37c0520a0b9c.

  2. luna-system commented on May 4, 2026

    @luna-system
    Contributor

    thank you for re-opening. we confirm your findings in the past 2 hours of hell we've spent poring through the codebase and the "logs".

  3. bl0xsmith commented on May 4, 2026

    @bl0xsmith

    I can confirm that this is also happening for me with discord channel.

  4. luna-system commented on May 4, 2026

    @luna-system
    Contributor

    it's possible that a patch for the secrets key is needed as well (it was for our multi-agent, multi-secret setup)

    // added to discord/dist/index.js:
    secrets: {
        specifier: "./secret-contract-api.js",
        exportName: "secretTargetRegistryEntries"
    },
  5. self-assigned this
    on May 4, 2026
  6. khaney64 commented on May 4, 2026

    @khaney64

    rather than open another issue, adding information here, I think it's related.

    I am seeing the same class of failure on openclaw@2026.5.3-1, but with two extra affected paths/accounts.

    Environment:

    • OpenClaw 2026.5.3-1 (2eae30e)
    • Linux systemd gateway
    • Gateway process env contains:
      • DISCORD_BOT_TOKEN
      • DISCORD_BOT_TOKEN_SUBAGENT
    • channels.discord.token / channels.discord.accounts.default.token use env:default:DISCORD_BOT_TOKEN
    • channels.discord.accounts.subagent.token uses env:default:DISCORD_BOT_TOKEN_SUBAGENT

    Observed:

    Recent logs:

    exec approval followup dispatch failed (...): Discord bot token configured for account "default" is unavailable; resolve
    SecretRefs against the active runtime snapshot before using this account.
    
    Delivery failed (discord to channel:...): Error: Discord bot token configured for account "default" is unavailable;
    resolve SecretRefs against the active runtime snapshot before using this account.
    
  7. added a commit that references this issue on May 4, 2026
    43b5df7
  8. added a commit that references this issue on May 6, 2026
    afc0814
  9. locked as resolved and limited conversation to collaborators on May 7, 2026
  10. added a commit that references this issue on May 24, 2026
    b52323e
  11. added a commit that references this issue on Jun 2, 2026
    5c0055a
  12. added a commit that references this issue on Jun 10, 2026
    75139bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions