fix(messaging): restore per-account Discord proxy for gateway WebSocket#5081
fix(messaging): restore per-account Discord proxy for gateway WebSocket#5081latenighthackathon wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR restores per-account proxy assignment for Discord in the OpenClaw config generator (matching Telegram) and updates tests to assert the Discord account proxy is written in managed, per-account, deferred, loopback, and combined routing scenarios. ChangesDiscord Gateway Proxy Configuration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
The Discord gateway client honors only the per-account proxy, not the managed env proxy, so without channels.discord.accounts.default.proxy it resolves gateway.discord.gg via direct DNS and fails with EAI_AGAIN in a proxy-only sandbox, leaving the inbound half of Discord black-holed. NVIDIA#3935 set this proxy to fix NVIDIA#3894. The config-generator port in NVIDIA#4277 narrowed the per-account proxy assignment to Telegram only, relying on the top-level managed proxy to cover Discord. The managed proxy is applied via HTTP(S)_PROXY env injection, but the gateway client builds its own ws agent and tunnels only when the per-account proxy is set (verified in OpenClaw 2026.5.18, 2026.5.27, and 2026.6.1), so the change re-regressed NVIDIA#3894. Restore Discord to the per-account proxy assignment, mirroring Telegram, and update the generator tests accordingly. Closes NVIDIA#5075 Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
ad3a1d7 to
5cf4bd9
Compare
|
✨ Thanks for submitting this PR restoring the per-account Discord proxy for the gateway WebSocket. This proposes a way to fix the regression where the Discord bot sends via REST API but never establishes the Gateway WebSocket connection in proxy-only sandboxes. Related open PRs:
Related open issues: |
prekshivyas
left a comment
There was a problem hiding this comment.
Reviewed (code + security checklist). Re-adds account.proxy for the Discord channel (alongside Telegram) in the config generator so channels.discord.accounts.default.proxy is emitted again and the gateway WebSocket routes through the sandbox proxy; updates 6 test cases. Re-fix of the #3894 → #4277 regression.
✅ Approve. Verified against source:
- On
mainonlytelegramreceivedaccount.proxy; this widens the condition totelegram || discordwhile keepinggroupPolicy:"open"Telegram-only — confirmed at main vs. head. No change for Slack/WhatsApp. - The per-account proxy reuses the same managed sandbox egress
proxyUrl(http://${NEMOCLAW_PROXY_HOST||10.200.0.1}:${PORT||3128}) that feedsconfig.proxy— no new/attacker-controllable destination, so no new SSRF surface; traffic stays on the existing egress path. - The 6 flipped test assertions are consistent (incl. the loopback-decoy case correctly still expecting the default).
Security: all 9 pass — no token/credential in the proxy value, no logging change.
One caveat (couldn't verify here): the load-bearing assumption is that OpenClaw's Discord gateway plugin honors the per-account proxy for the WebSocket (and ignores HTTP_PROXY for it). That code is in the external OpenClaw package, not in this repo, so I couldn't confirm it from source — it rests on the e2e rationale from #3935/#5075. Worth confirming the gateway-connect e2e (socket connects, MESSAGE_CREATE received) in CI/staging before relying on it. Approving on the config-generator change, which is correct and well-tested.
Nit: the import reordering in the test file is unrelated noise (harmless).
|
Closing this in favor of a fresh PR: an upstream refactor moved channel-config generation out of The underlying bug (#5075) is still present, just relocated: |
…WebSocket connects (#5248) ## Summary A sandbox with the Discord channel comes up degraded: the bot sends via the Discord REST API but never establishes the gateway WebSocket, so it receives zero inbound events. This is the regression tracked in #5075 (originally #3894). `channels.discord.accounts.default.proxy` is rendered from the `{{discordProxyUrl}}` template, but `src/lib/messaging/channels/discord/template-resolver.ts` resolved that reference to `undefined`, so the Discord account was emitted with no proxy. The Discord gateway client honors only the per-account proxy (it ignores the managed env proxy), so the gateway WebSocket cannot egress the deny-by-default sandbox network namespace. Telegram's resolver already resolves its `proxyUrl` to the sandbox proxy; Discord was the lone gap. ## Related Issue Closes #5075. > Note: an earlier PR (#5081) fixed this in `scripts/generate-openclaw-config.mts`, but channel-config generation has since moved to the manifest + template-resolver path, so that fix site no longer exists. This re-targets the same bug at the current site. ## Changes - `src/lib/messaging/channels/discord/template-resolver.ts`: resolve `discordProxyUrl` to the sandbox proxy URL (`NEMOCLAW_PROXY_HOST`/`NEMOCLAW_PROXY_PORT`, default `http://10.200.0.1:3128`) instead of `undefined`, mirroring the telegram resolver. - `test/discord-template-resolver-proxy.test.ts`: assert `discordProxyUrl` resolves to the default proxy and honors host/port overrides. ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) ## Verification - `npx vitest run --project cli test/discord-template-resolver-proxy.test.ts test/messaging-build-applier.test.ts` — 18/18 pass - `npm run typecheck:cli` and `npm run build:cli` — clean Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Discord messaging now consistently resolves a proxy URL, using configured host/port or sensible defaults. * **Bug Fixes** * Fixed case where Discord proxy URL could be missing; now reliably populated. * **Tests** * Added and updated tests to validate Discord proxy URL resolution for default and custom proxy configurations. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com> Co-authored-by: latenighthackathon <latenighthackathon@users.noreply.github.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com>
Summary
A sandbox onboarded with the Discord channel comes up degraded: the bot sends via the Discord REST API but never establishes the Discord Gateway WebSocket, so it receives zero inbound
MESSAGE_CREATE/ mention events. This is the same symptom as #3894.The Discord gateway client honors only the per-account proxy (
channels.discord.accounts.default.proxy), not the managed env proxy. Inextensions/discord/src/monitor/gateway-plugin.ts, the gateway socket is opened with the classicwstransport and an explicit agent that tunnels through the proxy only when the per-account value is set; otherwise it falls back to a direct-DNShttps.Agent, which has no resolver to answer in a proxy-only sandbox (EAI_AGAIN). This is unchanged across OpenClaw 2026.5.18, 2026.5.27, and 2026.6.1, so a version bump does not address it.#3935 set the per-account Discord proxy to fix #3894. The config-generator port in #4277 narrowed the per-account proxy assignment to Telegram only, relying on the top-level managed proxy (applied via
HTTP(S)_PROXYenv injection) to cover Discord. The gateway client does not read those env vars, so dropping the per-account proxy re-regressed #3894.This restores Discord to the per-account proxy assignment, mirroring Telegram.
Related Issue
Closes #5075 (re-regression of #3894).
Changes
scripts/generate-openclaw-config.mts: setaccount.proxy = proxyUrlfor Discord as well as Telegram, so the generatedchannels.discord.accounts.default.proxyroutes the gateway client through the sandbox proxy. Telegram keeps itsgroupPolicy: "open".test/generate-openclaw-config.test.ts: update the Discord proxy expectations (previously asserted absent) to expect the per-account proxy, and rename the affected cases.Type of Change
Verification
npx vitest run --project cli test/generate-openclaw-config.test.ts— 133/133 passnpm run typecheck:cli— cleanSigned-off-by: latenighthackathon latenighthackathon@users.noreply.github.com
Summary by CodeRabbit
Bug Fixes
Tests