Skip to content

fix(feishu): disable ambient proxy inheritance for websocket by default - #65802

Closed
songbing0632-code wants to merge 1 commit into
openclaw:mainfrom
songbing0632-code:fix/feishu-ws-no-ambient-proxy
Closed

songbing0632-code wants to merge 1 commit into
openclaw:mainfrom
songbing0632-code:fix/feishu-ws-no-ambient-proxy

Conversation

@songbing0632-code

Copy link
Copy Markdown

Summary

  • stop Feishu WebSocket from inheriting ambient proxy env by default
  • add an explicit OPENCLAW_FEISHU_WS_USE_PROXY=1 opt-in for proxy usage
  • update Feishu WS proxy tests to cover the new default and opt-in behavior

Why

Feishu inbound can silently break when the gateway process inherits unrelated proxy env, especially ALL_PROXY pointing at an unavailable local SOCKS endpoint. In that case Feishu WS only logs a generic ws connect failed, while direct connection with the same app credentials succeeds.

This makes Feishu inbound fragile and hard to debug. A safer default is to bypass ambient proxy env for Feishu WS unless explicitly requested.

Testing

  • attempted local test run for extensions/feishu/src/client.test.ts
  • current temporary clone needed dependency installation first
  • live gateway verification on a real install confirmed:
    • Feishu WS failed when ambient proxy inheritance was enabled
    • Feishu WS recovered immediately after bypassing proxy inheritance
    • real Feishu -> OpenClaw -> worker reply path resumed successfully

Closes #65799

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: XS labels Apr 13, 2026
@greptile-apps

greptile-apps Bot commented Apr 13, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a reliability bug in the Feishu WebSocket client by making proxy usage opt-in via OPENCLAW_FEISHU_WS_USE_PROXY=1 instead of silently inheriting ambient proxy env vars. The production change in client.ts is clean and correct.

  • The new test for "does not inherit ambient proxy env by default" and the updated opt-in tests cover the right behavior, but OPENCLAW_FEISHU_WS_USE_PROXY is not restored in afterEach, causing env leakage across tests in --isolate=false runs (the repo's default pool).

Confidence Score: 4/5

Safe to merge after fixing the env cleanup leak in the test file; production logic is correct.

The production change is sound, but the missing afterEach cleanup for OPENCLAW_FEISHU_WS_USE_PROXY is a real test isolation defect (P1) that can cause other tests to silently enable proxy behavior when run with --isolate=false.

extensions/feishu/src/client.test.ts — missing afterEach restore for FEISHU_WS_USE_PROXY_ENV_VAR

Comments Outside Diff (1)

  1. extensions/feishu/src/client.test.ts, line 361-405 (link)

    P1 OPENCLAW_FEISHU_WS_USE_PROXY not cleaned up between tests

    process.env.OPENCLAW_FEISHU_WS_USE_PROXY = "1" is set in three test cases but never restored in afterEach. The existing cleanup loop only covers proxyEnvKeys (https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY) and FEISHU_HTTP_TIMEOUT_ENV_VAR. With --isolate=false (the repo's default non-fork pool), this value leaks into every subsequent test in the process, potentially enabling proxy logic in unrelated tests.

    The fix is to track and restore FEISHU_WS_USE_PROXY_ENV_VAR the same way FEISHU_HTTP_TIMEOUT_ENV_VAR already is:

    // in beforeEach, alongside the existing priorFeishuTimeoutEnv save:
    priorFeishuWsUseProxyEnv = process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
    delete process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
    
    // in afterEach:
    if (priorFeishuWsUseProxyEnv === undefined) {
      delete process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
    } else {
      process.env[FEISHU_WS_USE_PROXY_ENV_VAR] = priorFeishuWsUseProxyEnv;
    }
    
    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: extensions/feishu/src/client.test.ts
    Line: 361-405
    
    Comment:
    **`OPENCLAW_FEISHU_WS_USE_PROXY` not cleaned up between tests**
    
    `process.env.OPENCLAW_FEISHU_WS_USE_PROXY = "1"` is set in three test cases but never restored in `afterEach`. The existing cleanup loop only covers `proxyEnvKeys` (`https_proxy`, `HTTPS_PROXY`, `http_proxy`, `HTTP_PROXY`) and `FEISHU_HTTP_TIMEOUT_ENV_VAR`. With `--isolate=false` (the repo's default non-fork pool), this value leaks into every subsequent test in the process, potentially enabling proxy logic in unrelated tests.
    
    The fix is to track and restore `FEISHU_WS_USE_PROXY_ENV_VAR` the same way `FEISHU_HTTP_TIMEOUT_ENV_VAR` already is:
    
    ```
    // in beforeEach, alongside the existing priorFeishuTimeoutEnv save:
    priorFeishuWsUseProxyEnv = process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
    delete process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
    
    // in afterEach:
    if (priorFeishuWsUseProxyEnv === undefined) {
      delete process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
    } else {
      process.env[FEISHU_WS_USE_PROXY_ENV_VAR] = priorFeishuWsUseProxyEnv;
    }
    ```
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/feishu/src/client.test.ts
Line: 361-405

Comment:
**`OPENCLAW_FEISHU_WS_USE_PROXY` not cleaned up between tests**

`process.env.OPENCLAW_FEISHU_WS_USE_PROXY = "1"` is set in three test cases but never restored in `afterEach`. The existing cleanup loop only covers `proxyEnvKeys` (`https_proxy`, `HTTPS_PROXY`, `http_proxy`, `HTTP_PROXY`) and `FEISHU_HTTP_TIMEOUT_ENV_VAR`. With `--isolate=false` (the repo's default non-fork pool), this value leaks into every subsequent test in the process, potentially enabling proxy logic in unrelated tests.

The fix is to track and restore `FEISHU_WS_USE_PROXY_ENV_VAR` the same way `FEISHU_HTTP_TIMEOUT_ENV_VAR` already is:

```
// in beforeEach, alongside the existing priorFeishuTimeoutEnv save:
priorFeishuWsUseProxyEnv = process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
delete process.env[FEISHU_WS_USE_PROXY_ENV_VAR];

// in afterEach:
if (priorFeishuWsUseProxyEnv === undefined) {
  delete process.env[FEISHU_WS_USE_PROXY_ENV_VAR];
} else {
  process.env[FEISHU_WS_USE_PROXY_ENV_VAR] = priorFeishuWsUseProxyEnv;
}
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "fix(feishu): disable ambient proxy inher..." | Re-trigger Greptile

@clawsweeper

clawsweeper Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Workflow note: Future ClawSweeper reviews update this same comment in place.

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.

Summary
The PR changes Feishu WebSocket proxy handling so ambient proxy env is ignored by default and only used when OPENCLAW_FEISHU_WS_USE_PROXY=1 is set.

Reproducibility: yes. On current main, setting proxy env before createFeishuWSClient() follows getWsProxyAgent() to resolveAmbientNodeProxyAgent() and passes an agent into Lark WSClient; related comments also include real failure logs.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Summary: The production direction is useful, but missing real proof plus managed-proxy and test-cleanup blockers make the PR not quality-ready yet.

Rank-up moves:

  • Add redacted after-fix logs, terminal output, or a recording from a real Feishu gateway with ambient proxy env set.
  • Update the patch to preserve managed proxy behavior separately from stray ambient proxy env.
  • Restore the new env var in test cleanup and document the opt-in.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

Real behavior proof
Needs stronger real behavior proof before merge: The PR body has claimed live verification and related workaround logs, but no inspectable after-fix proof from the patched branch with ambient proxy env still set. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • Existing deployments that need Feishu WS to use HTTP_PROXY or HTTPS_PROXY may lose inbound Feishu delivery after upgrade unless they discover and set the new opt-in.
  • The patch does not distinguish unrelated ambient shell proxy env from OpenClaw managed proxy mode, where proxy.enabled intentionally injects proxy env for runtime egress.
  • The branch is now conflicting with main, and the PR still lacks inspectable patched-branch proof from a real Feishu gateway.

Maintainer options:

  1. Preserve managed proxy separately (recommended)
    Change the guard so unmanaged ambient proxy env is bypassed by default while proxy.enabled/OPENCLAW_PROXY_ACTIVE continues to route Feishu WS through the operator-managed proxy, with tests for both paths.
  2. Accept direct-by-default as policy
    Maintainers can intentionally accept the compatibility change, but should require upgrade docs and live proof for proxy-required Feishu deployments before merge.
  3. Pause for proxy design
    If env-only opt-in is not the desired surface, pause this PR and resolve the canonical Feishu proxy issue with a config-backed policy first.

Next step before merge
Needs human handling because the remaining blockers include external real-environment proof, merge conflicts, and a Feishu proxy policy/security-boundary decision.

Security
Needs attention: The diff has no supply-chain changes, but it changes Feishu WebSocket behavior on OpenClaw's documented managed-proxy egress boundary.

Review findings

  • [P1] Preserve managed proxy routing — extensions/feishu/src/client.ts:81-83
  • [P2] Restore the Feishu WS proxy env after each test — extensions/feishu/src/client.test.ts:371
  • [P3] Document the Feishu WebSocket proxy opt-in — extensions/feishu/src/client.ts:73
Review details

Best possible solution:

Keep the Feishu-owned direct-by-default fix, but preserve managed proxy routing, restore test env state, document the opt-in and upgrade behavior, and require real patched-branch proof before merge.

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

Yes. On current main, setting proxy env before createFeishuWSClient() follows getWsProxyAgent() to resolveAmbientNodeProxyAgent() and passes an agent into Lark WSClient; related comments also include real failure logs.

Is this the best way to solve the issue?

No, not as submitted. The narrow Feishu fix is plausible, but it needs managed-proxy handling, env cleanup, docs, conflict resolution, and after-fix proof before it is the maintainable solution.

Label justifications:

  • P1: The PR targets a real Feishu inbound delivery regression where proxy env can stop WebSocket message intake for affected users.
  • merge-risk: 🚨 compatibility: Changing Feishu WS from ambient-proxy inheritance to direct-by-default can break existing proxy-required deployments unless they opt in.
  • merge-risk: 🚨 message-delivery: A wrong proxy default can make Feishu WebSocket fail and stop inbound messages from arriving.
  • merge-risk: 🚨 security-boundary: OpenClaw managed proxy mode is a documented egress guardrail, and the PR currently gates proxy-agent creation without handling that policy separately.
  • rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦐 gold shrimp, and The production direction is useful, but missing real proof plus managed-proxy and test-cleanup blockers make the PR not quality-ready yet.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body has claimed live verification and related workaround logs, but no inspectable after-fix proof from the patched branch with ambient proxy env still set. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Full review comments:

  • [P1] Preserve managed proxy routing — extensions/feishu/src/client.ts:81-83
    The new guard disables every explicit Feishu WS proxy agent unless OPENCLAW_FEISHU_WS_USE_PROXY=1 is set. OpenClaw managed proxy mode deliberately injects HTTP_PROXY/OPENCLAW_PROXY_ACTIVE and documents runtime WebSocket routing through proxy.enabled, so this can route Feishu WS direct or leave that security path untested. Keep the fix for stray ambient env, but continue honoring managed proxy state with coverage.
    Confidence: 0.82
  • [P2] Restore the Feishu WS proxy env after each test — extensions/feishu/src/client.test.ts:371
    The new opt-in tests set process.env.OPENCLAW_FEISHU_WS_USE_PROXY, but the suite cleanup only restores generic proxy env keys and FEISHU_HTTP_TIMEOUT_ENV_VAR. Since the shared Vitest config uses isolate: false, later tests in the worker can unexpectedly see Feishu WS proxy opt-in enabled.
    Confidence: 0.92
  • [P3] Document the Feishu WebSocket proxy opt-in — extensions/feishu/src/client.ts:73
    This adds a new operator-facing env var and changes Feishu WebSocket proxy defaults, but the Feishu and network proxy docs do not mention the direct default, escape hatch, or managed-proxy interaction. Add docs so affected operators can migrate intentionally.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.86

Security concerns:

  • [medium] Managed proxy boundary needs explicit handling — extensions/feishu/src/client.ts:81
    OpenClaw managed proxy mode injects proxy env and documents runtime WebSocket routing through the operator-managed proxy; gating Feishu's explicit WS proxy agent behind a new Feishu-only env var could bypass or leave unproved that egress guardrail.
    Confidence: 0.82

Acceptance criteria:

  • node scripts/run-vitest.mjs extensions/feishu/src/client.test.ts
  • pnpm docs:list before docs edits, then inspect docs/channels/feishu.md and docs/security/network-proxy.md
  • node scripts/crabbox-wrapper.mjs run --shell -- "pnpm check:changed"

What I checked:

Likely related people:

  • colin719: Authored the merged Feishu WS proxy-agent support that this PR narrows. (role: introduced adjacent behavior; confidence: high; commits: 0a23739c3795, beaf5eab2910; files: extensions/feishu/src/client.ts, extensions/feishu/src/client.test.ts)
  • Takhoffman: Contributed follow-up commits wiring Feishu proxy dependency and coverage before the original proxy support merged. (role: adjacent merged-feature contributor; confidence: medium; commits: 3ae547fc520e, efb484564eee; files: extensions/feishu/src/client.ts, extensions/feishu/src/client.test.ts, extensions/feishu/package.json)
  • steipete: Authored the shared ambient proxy helper refactor now used by Feishu WS proxy handling. (role: shared proxy helper contributor; confidence: medium; commits: 380a39626687; files: src/plugin-sdk/extension-shared.ts, extensions/feishu/src/client.ts, extensions/feishu/src/client.test.ts)
  • vincentkoc: Recently merged Feishu WebSocket reconnect and heartbeat changes touching the same client and transport surfaces. (role: recent Feishu WebSocket contributor; confidence: medium; commits: d93e6f61580a, 217a8fbd4dd6; files: extensions/feishu/src/client.ts, extensions/feishu/src/client.test.ts, extensions/feishu/src/monitor.transport.ts)
  • m1heng: The Feishu package metadata declares the plugin as community maintained by this handle, which is relevant for Feishu-specific proxy policy. (role: plugin routing candidate; confidence: medium; files: extensions/feishu/package.json)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 447a3643c69b.

@googlerest

Copy link
Copy Markdown
Contributor

Adding real-world confirmation of this bug.

My setup: macOS 26.4.1 (arm64), OpenClaw 2026.5.3-1, HTTP_PROXY=http://127.0.0.1:7890 injected into gateway launchd plist for Gemini API access.

Gateway logs show repeated ws connect failed errors spanning several days:

2026-04-28T22:30:29.621+08:00 [error]: [ '[ws]', 'connect failed' ]
2026-04-29T00:23:22.395+08:00 [error]: [ '[ws]', 'connect failed' ]
2026-04-30T02:23:30.163+08:00 [error]: [ '[ws]', 'ws connect failed' ]
2026-05-01T00:44:03.197+08:00 [error]: [ '[ws]', 'connect failed' ]

Removing HTTP_PROXY from the plist resolved the Feishu WS connection. This confirms the fix in this PR is correct — Feishu WS should not inherit ambient proxy env by default.

@mebusw

mebusw commented May 9, 2026

Copy link
Copy Markdown

please resolve this issue, better not only enable/disable by env variable switch, but also add a flag in openclaw.json, just like what Discord extension did:
that Discord extension by defaults inherit the gloabl proxy of openclaw

  "proxy": {
    "enabled": true,
    "proxyUrl": "http://127.0.0.1:7890"
  },

and also it has own flag

  "channels": {
    "discord": {
      "enabled": true,
      "proxy": "http://127.0.0.1:7890",
      ...

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels May 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 20, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@openclaw-barnacle

Copy link
Copy Markdown

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

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 5, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feishu WebSocket should not inherit ambient proxy env by default

3 participants