Repository navigation
Description
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)
openclaw@2026.5.3-1installed (npm view openclaw version→2026.5.3-1);@openclaw/discord@2026.5.3plugin installed at~/.openclaw/npm/node_modules/@openclaw/discord/.~/.openclaw/openclaw.jsonincludes:{ "secrets": { "providers": { "default": { "source": "env" } } }, "channels": { "discord": { "enabled": true, "token": { "source": "env", "provider": "default", "id": "DISCORD_BOT_TOKEN" } } } }DISCORD_BOT_TOKENis set in the gateway service's env (via~/.openclaw/.envautoload).- 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 providerlog line. Plugin is loaded (counted in9 plugins: ...; discord; ...) but channel never starts. openclaw channels statusshows:Discord default: enabled, configured, secret unavailable in this command path, stopped, disconnected, token:config (unavailable), health:not-running, error:not configuredopenclaw status --deepchannels table:Discord │ ON │ WARN │ configured token unavailable in this command path- Removing the
channels.discord.tokenblock (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
- Pre-fix(secretrefs): resolve external channel contracts #76449 (2026.5.2):
normalizeDiscordTokenused the strict resolver which threw → loud crash. - Post-fix(secretrefs): resolve external channel contracts #76449 (2026.5.3-1):
resolveDiscordTokenusesmode: "inspect"which gracefully returnsconfigured_unavailable. The framework path then bails onisConfigured === falsewithout logging anything channel-specific.
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.3installed at~/.openclaw/npm/node_modules/@openclaw/discord/ - Build artifact verified on disk:
dist/secret-contract-api.jsexists, root-levelsecret-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.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 4, 2026
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:
src/secrets/channel-contract-api.ts:89, 37c0520a0b9c)src/secrets/channel-contract-api.ts:116, 37c0520a0b9c)src/secrets/channel-contract-api.external.test.ts:30, 37c0520a0b9c)docs/channels/discord.md. (docs/channels/discord.md:99, 37c0520a0b9c)extensions/discord/src/token.ts:86, 37c0520a0b9c)docs/plugins/sdk-entrypoints.md. (docs/plugins/sdk-entrypoints.md:17, 37c0520a0b9c)Likely related people:
src/secrets/channel-contract-api.ts,src/secrets/channel-contract-api.external.test.ts,CHANGELOG.md)CHANGELOG.md,extensions/discord/package.json,docs/plugins/sdk-entrypoints.md)src/secrets/channel-contract-api.ts,src/secrets/channel-contract-api.external.test.ts)Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 37c0520a0b9c.
luna-system commentedon May 4, 2026
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".
bl0xsmith commentedon May 4, 2026
I can confirm that this is also happening for me with discord channel.
luna-system commentedon May 4, 2026
it's possible that a patch for the secrets key is needed as well (it was for our multi-agent, multi-secret setup)
khaney64 commentedon May 4, 2026
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:
DISCORD_BOT_TOKENDISCORD_BOT_TOKEN_SUBAGENTchannels.discord.token/channels.discord.accounts.default.tokenuseenv:default:DISCORD_BOT_TOKENchannels.discord.accounts.subagent.tokenusesenv:default:DISCORD_BOT_TOKEN_SUBAGENTObserved:
openclaw statusreports:configured token unavailable in this command path · accounts 2Recent logs:
fix(secretrefs): resolve external channel contracts in dist/ sidecars (…
fix(secretrefs): resolve external channel contracts in dist/ sidecars (…
fix(secretrefs): resolve external channel contracts in dist/ sidecars (…
fix(secretrefs): resolve external channel contracts in dist/ sidecars (…
fix(secretrefs): resolve external channel contracts in dist/ sidecars (…