test(discord): clarify and guardrail gateway proxy selection#98272
test(discord): clarify and guardrail gateway proxy selection#98272svuppala2006 wants to merge 2 commits into
Conversation
|
Codex review: found issues before merge. Reviewed July 1, 2026, 7:52 PM ET / 23:52 UTC. Summary PR surface: Source +65, Tests +299, Docs +1. Total +365 across 6 files. Reproducibility: yes. Source inspection shows current main keeps Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land this after owner/security review accepts the explicit process-proxy trust boundary and the generated docs map is refreshed; keep broader proxy semantics in #60035. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main keeps Is this the best way to solve the issue? Unclear until owner/security review accepts the policy. The explicit proxy guardrail is narrower than ambient env fallback and matches the closed related decision, but the docs map must be regenerated before this is merge-ready. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 17482a402680. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +65, Tests +299, Docs +1. Total +365 across 6 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…bSocket Discord Gateway WebSocket connections now honor HTTP_PROXY/HTTPS_PROXY environment variables as fallback before direct connection, matching the existing pattern from Discord REST API and WhatsApp. This enables Discord channel deployment in Kubernetes/OpenShift environments with network policy egress restrictions, removing the need for broad :443 egress as a workaround. - Add createEnvProxyDiscordGatewayAgent() helper (mirrors rest-fetch.ts pattern) - Try env proxy before direct HttpsAgent in createDiscordGatewayPlugin() - Explicit channels.discord.proxy still overrides env proxy - Add formatErrorMessage and resolveEnvHttpProxyAgentOptions imports Fixes #98266
9974fb8 to
605b9eb
Compare
|
I'm testing that proxy can be configured with |
Signed-off-by: sallyom <[email protected]>
605b9eb to
0add562
Compare
|
@clawsweeper review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
What Problem This Solves
Restricted Kubernetes/OpenShift deployments need Discord Gateway and Discord REST traffic to leave the Gateway pod through the managed proxy, not through broad direct
:443egress.This PR intentionally keeps Discord Gateway proxying explicit. Discord does not auto-inherit ambient
HTTP_PROXY/HTTPS_PROXY/ALL_PROXYfor Gateway sessions. Instead, deployments configurechannels.discord.proxy, and OpenClaw now permits a non-loopback proxy URL only when it exactly matches the effective configured process proxy URL.That gives operators a safe MITM proxy path for Discord without accepting arbitrary remote proxy hosts in Discord config.
Why This Change Was Made
The existing Discord proxy validator only accepted loopback proxy hosts. That blocked operator-managed proxy services such as:
The new validation allows this only when the configured proxy matches the effective process proxy endpoint, including normalized full URL, credentials, port, and lower/upper-case env precedence. Arbitrary DNS hosts and non-loopback IPs remain rejected.
User Impact
Users in restricted-egress environments can run Discord through a configured proxy without granting broad Gateway pod
:443egress.Supported path:
Deployment environments that set
HTTPS_PROXY=http://higgins-proxy:8080can use the same endpoint explicitly inchannels.discord.proxy. The Gateway does not silently opt into proxying just because proxy env vars are present.Evidence
Automated Tests
Focused local tests passed:
git diff --checkpassed.Autoreview passed after fixes:
Real Behavior Proof
Environment: K8s cluster, namespace
sallyom-claw, Clawhiggins, Discord test serverTest Claws, botTest.Image under test:
The Discord plugin loaded from the rebuilt OpenClaw image:
{ "source": "/app/dist/extensions/discord/index.js", "origin": "bundled", "status": "loaded" }Gateway logs showed both proxy paths enabled:
Discord channel status showed the bot connected:
{ "channels": { "discord": { "configured": true, "running": true, "lastError": null } }, "channelAccounts": { "discord": [ { "accountId": "default", "running": true, "connected": true, "tokenStatus": "available", "bot": { "username": "Test" } } ] } }The Gateway egress NetworkPolicy had no broad
:443rule. It allowed only the proxy pod on:8080plus DNS:A live Discord REST proof message was posted through the MITM proxy:
{ "proxy": "http://some-proxy:8080", "guild": "Test", "textChannel": "general", "messageCreated": true, "content": "OpenClaw final Discord proxy proof 2026-07-01T23:17:06.190Z" }Discord status then showed inbound Gateway activity:
{ "connected": true, "lastInboundAt": 1782947826282, "lastTransportActivityAt": 1782947816644, "lastError": null }Related
channels.discord.proxyfor token-bearing Discord Gateway routing.