Skip to content

fix(feishu): route SDK traffic through ambient proxy - #86386

Merged
steipete merged 5 commits into
openclaw:mainfrom
itsyujay:fix-feishu-proxy-http-instance
Jul 15, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
itsyujay:fix-feishu-proxy-http-instance

Conversation

@itsyujay

@itsyujay itsyujay commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

AI-assisted contribution.

What Problem This Solves

Feishu REST calls, WebSocket endpoint discovery, and the WebSocket connection itself did not share one ambient proxy transport. Proxy-only deployments could therefore fail during token/API calls or WebSocket startup even when HTTP_PROXY / HTTPS_PROXY was configured.

Fixes #48949.

Why This Change Was Made

  • Resolve one process-scoped ProxylineNodeProxyAgent and reuse it across Feishu REST, SDK bootstrap, and WebSocket traffic.
  • Preserve caller-provided HTTP agents in ordinary ambient-proxy mode.
  • Override caller agents and fail closed when OpenClaw managed-proxy mode is active, preventing direct-network bypass.
  • Keep Axios ambient proxy behavior available if ordinary unmanaged agent construction fails.

The Feishu SDK exposes separate httpInstance and WebSocket agent seams; using the same dual-protocol Proxyline agent at both seams keeps ownership in the Feishu plugin and preserves connection pooling.

User Impact

Feishu installations behind an HTTP(S) proxy can authenticate, complete WebSocket endpoint discovery, and maintain the WebSocket session through the configured proxy. No new configuration is introduced.

Evidence

  • Blacksmith Testbox: pnpm test extensions/feishu/src/client.test.ts — 24/24 passed.
  • Blacksmith Testbox: targeted oxfmt --check passed for the touched TypeScript files and changelog.
  • Live Testbox probe traversed a real local CONNECT proxy to open.feishu.cn:443; fake credentials reached Feishu and failed authentication only after the proxy tunnel succeeded.
  • Contributor live environment: WSL2 Ubuntu, OpenClaw 2026.5.22, systemd gateway, and HTTP_PROXY / HTTPS_PROXY / OPENCLAW_PROXY_URL configured. After applying the equivalent installed-package fix, openclaw channels status --channel feishu --deep --probe reported enabled, configured, running, works; logs reported the bot identity resolved and WebSocket client ready without the prior HTTP-to-HTTPS failure.
  • Fresh maintainer autoreview: clean, confidence 0.91.
  • Exact-head GitHub CI: pending for af7b69515f1a3df25d0279d3bad6f70e4341e746.

Testbox run: https://github.com/openclaw/openclaw/actions/runs/29390928814

@openclaw-barnacle openclaw-barnacle Bot added channel: feishu Channel integration: feishu size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 29, 2026, 3:08 PM ET / 19:08 UTC.

Summary
This PR replaces Feishu's timeout-only Lark SDK HTTP wrapper with a proxy-aware wrapper, wires it into both Lark Client and WSClient bootstrap, and adds client tests for ambient proxy, caller-agent preservation, and managed-proxy override.

PR surface: Source +27, Tests +117. Total +144 across 2 files.

Reproducibility: yes. at source level. Current main uses a timeout-only Feishu SDK HTTP wrapper and no WS bootstrap httpInstance, while the pinned Lark SDK uses httpInstance for tenant-token requests and WS pullConnectConfig; the PR body also includes live terminal proof from an equivalent installed-package hotfix.

Review metrics: 1 noteworthy metric.

  • Feishu SDK HTTP surfaces: 2 changed: REST/token HTTP and WS bootstrap HTTP. Both credentialed Feishu API calls and WebSocket setup now depend on the accepted proxy routing contract before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #48949
Summary: This PR is the active candidate fix for the linked Feishu tenant_access_token proxy issue; several related Feishu proxy reports overlap but do not supersede it.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

Maintainer options:

  1. Approve The Feishu Proxy Contract (recommended)
    If maintainers want Feishu SDK HTTP to follow ambient and managed proxy routing, accept the compatibility and security tradeoff and merge after exact-head checks remain green.
  2. Narrow Ordinary Ambient Routing
    If ambient proxy inheritance is too broad, revise the PR so only managed-proxy mode forces the operator proxy and leave ordinary Feishu direct/proxy policy for a separate change.
  3. Pause For Per-Channel Policy
    If maintainers want an explicit Feishu channel-level proxy mode first, pause this PR and resolve the broader linked policy items before changing runtime egress behavior.

Next step before merge

  • [P2] Needs maintainer acceptance of the Feishu proxy/security contract; there is no narrow automated repair to queue from this review.

Security
Cleared: Cleared: the diff does not add dependencies, workflows, permissions, secret handling, or supply-chain changes; the intentional credentialed proxy boundary change is tracked as merge risk.

Review details

Best possible solution:

Accept or reject the Feishu proxy egress policy explicitly; if accepted, land this focused httpInstance fix and track broader per-channel direct/proxy controls separately.

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

Yes, at source level. Current main uses a timeout-only Feishu SDK HTTP wrapper and no WS bootstrap httpInstance, while the pinned Lark SDK uses httpInstance for tenant-token requests and WS pullConnectConfig; the PR body also includes live terminal proof from an equivalent installed-package hotfix.

Is this the best way to solve the issue?

Yes, with maintainer policy acceptance. Reusing the Lark SDK httpInstance seam inside the Feishu plugin is the narrow owner-boundary fix, while a channel-level direct/proxy mode is broader follow-up work for mixed-network setups.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 82dfd8910743.

Label changes

Label justifications:

  • P1: The linked failure blocks Feishu channel startup and message delivery for users whose gateway runs with proxy configuration.
  • merge-risk: 🚨 compatibility: The PR changes how existing Feishu installations route SDK HTTP under proxy env and managed proxy mode.
  • merge-risk: 🚨 message-delivery: Feishu token/API and WebSocket bootstrap routing directly affects whether the channel can send and receive messages.
  • merge-risk: 🚨 security-boundary: Managed proxy mode intentionally overrides caller-supplied agents so credentialed Feishu HTTP cannot bypass the operator proxy boundary.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Sufficient: the PR body includes redacted terminal output and gateway logs from a live OpenClaw gateway with an equivalent installed-package hotfix showing Feishu status/probe recovery and prior failure strings absent.
  • proof: sufficient: Contributor real behavior proof is sufficient. Sufficient: the PR body includes redacted terminal output and gateway logs from a live OpenClaw gateway with an equivalent installed-package hotfix showing Feishu status/probe recovery and prior failure strings absent.
Evidence reviewed

PR surface:

Source +27, Tests +117. Total +144 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 40 13 +27
Tests 1 119 2 +117
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 159 15 +144

What I checked:

  • Repository policy applied: Root and extensions AGENTS.md were read fully; their dependency-backed review and compatibility-sensitive plugin proxy guidance apply because the PR changes bundled Feishu SDK HTTP routing. (AGENTS.md:31, 82dfd8910743)
  • Current main lacks Feishu SDK HTTP proxy wiring: Current main creates a timeout-only Lark httpInstance that delegates to defaultHttpInstance without setting httpAgent, httpsAgent, proxy:false, or a Feishu-specific egress policy. (extensions/feishu/src/client.ts:129, 82dfd8910743)
  • Current main WSClient only receives the socket agent: Current main passes an ambient agent to WSClient but does not pass a proxy-aware httpInstance for WS pullConnectConfig bootstrap requests. (extensions/feishu/src/client.ts:222, 82dfd8910743)
  • PR implements the focused httpInstance repair: The PR adds createFeishuHttpInstance, resolves the ambient proxy agent, sets httpAgent/httpsAgent plus proxy:false, preserves caller agents outside managed proxy mode, and overrides agents when OPENCLAW_PROXY_ACTIVE=1. (extensions/feishu/src/client.ts:140, 0cde216c1e78)
  • PR covers both Lark Client and WS bootstrap: The PR passes the proxy-aware HTTP instance to the Lark Client and to WSClient, so tenant/API HTTP and pullConnectConfig use the same wrapper. (extensions/feishu/src/client.ts:204, 0cde216c1e78)
  • Focused tests cover the changed behavior: The PR adds tests for Feishu HTTP proxy-agent injection, preserving request-level agents, managed-proxy agent override, and WSClient bootstrap using the proxy-aware HTTP instance. (extensions/feishu/src/client.test.ts:474, 0cde216c1e78)

Likely related people:

  • ayanesakura: Commit ba223c7 added the Feishu timeout-aware HTTP wrapper that this PR extends from timeout-only behavior into proxy-aware routing. (role: introduced current HTTP wrapper behavior; confidence: medium; commits: ba223c776634; files: extensions/feishu/src/client.ts, extensions/feishu/src/client.test.ts)
  • colin719: Commit 0a23739 added Feishu WSClient proxy-agent support, the sibling behavior affected by this PR's WS bootstrap httpInstance change. (role: introduced related WebSocket proxy behavior; confidence: high; commits: 0a23739c3795; files: extensions/feishu/src/client.ts, extensions/feishu/src/client.test.ts)
  • steipete: Commits 380a396 and 59be6d6 moved plugin proxy handling through shared ambient proxy helpers and proxyline, which this PR reuses. (role: shared proxy helper contributor; confidence: high; commits: 380a39626687, 59be6d6390ea; files: src/plugin-sdk/extension-shared.ts, extensions/feishu/src/client.ts)
  • vincentkoc: Recent merged Feishu client and WebSocket recovery work touched the same client and transport area affected by this proxy-routing decision. (role: recent Feishu channel contributor; confidence: high; commits: f9b47ad2a169, d93e6f61580a, 282b9fe6168b; files: extensions/feishu/src/client.ts, extensions/feishu/src/client.test.ts)
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.

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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Pearl Patch Peep

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: guards the happy path.
Image traits: location proof lagoon; accessory CI status badge; palette moonlit blue and soft silver; mood sparkly; pose peeking out from the egg shell; shell glossy opal shell; lighting soft underwater shimmer; background subtle branch markers.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Pearl Patch Peep in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels May 25, 2026
@itsyujay

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the Feishu HTTP proxy wrapper to override request-level httpAgent/httpsAgent only while OpenClaw managed proxy mode is active (OPENCLAW_PROXY_ACTIVE=1), preserving caller-provided agents for ordinary ambient proxy env. Also updated the PR body with raw local behavior proof from the live Feishu gateway restart/probe.

@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 25, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels May 25, 2026
@BingqingLyu

This comment was marked as spam.

@itsyujay

Copy link
Copy Markdown
Contributor Author

@BingqingLyu Thanks for the heads-up. I checked the actual line-level changes between this PR and #86146 — they don't overlap:

The two PRs change disjoint regions of the same two files, and the intents are semantically independent (one fixes a test-infra cache-eviction bug; this one routes Lark SDK REST / WS bootstrap HTTP through the shared ambient proxy). Whichever lands first, the other should rebase cleanly without manual conflict resolution.

@xialonglee

Copy link
Copy Markdown
Contributor

why this still not merge yet? really need this

@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 Jul 14, 2026
@steipete steipete self-assigned this Jul 15, 2026
@itsyujay
itsyujay force-pushed the fix-feishu-proxy-http-instance branch from 0cde216 to 18ea754 Compare July 15, 2026 02:59
@itsyujay

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest origin/main to clear the merge conflict — the branch now sits cleanly on top of main (3 commits, no conflict markers).

Why it conflicted: main independently reworked extensions/feishu/src/client.ts while this PR was open:

How it was resolved: kept main's refactored structure as the base and re-applied this PR's proxy changes on top — isManagedProxyActive(), FeishuProxyAwareHttpRequestOptions, the createFeishuHttpInstance rename, the async injectRequestOptions (managed = vs. non-managed ??= agent branch + proxy: false), and httpInstance: createFeishuHttpInstance(...) on the WSClient. The stale evicts client cache test (which depended on the now-removed setFeishuClientRuntimeForTest) was dropped; the 4 new proxy tests were re-applied on the modernized vi.doMock test harness. Confirmed the Lark SDK's IConstructorParams accepts httpInstance, so dropping the cast still type-checks.

Local validation (Linux, Node 22.22.3):

  • extensions/feishu/src/client.test.ts — 22 passed.
  • tsgo:extensions (prod types) — clean.
  • tsgo:extensions:test (test types) — clean.
  • oxfmt --check on both changed files — clean.

@vincentkoc you owned the localize internal declarations refactor that overlapped most with this change — could you take a look at the resolution when you have a moment? 🙏

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 15, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 15, 2026
@steipete steipete changed the title fix(feishu): route SDK HTTP through ambient proxy fix(feishu): route SDK traffic through ambient proxy Jul 15, 2026
@steipete

Copy link
Copy Markdown
Contributor

Land-ready at 5474ce99cbaae1a31814d833cce9c4ad6a10a80c.

Maintainer work completed:

  • Replaced per-call proxy construction with one process-scoped ambient proxy agent shared by Feishu REST, SDK bootstrap, and WebSocket paths.
  • Preserved caller-provided agents outside managed OpenClaw proxy mode and retained the upstream SDK's Axios fallback behavior.
  • Added lifecycle-safe reset coverage and an Unreleased changelog entry thanking @larry-xue.

Proof:

Known proof gaps: none.

@steipete
steipete merged commit d43c8ec into openclaw:main Jul 15, 2026
97 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 16, 2026
* fix(feishu): route sdk http through ambient proxy

* fix(feishu): preserve request agents under proxy

* fix(feishu): honor managed proxy agent override

* fix(feishu): share ambient proxy transport

* chore(feishu): move release note to pr

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* fix(feishu): route sdk http through ambient proxy

* fix(feishu): preserve request agents under proxy

* fix(feishu): honor managed proxy agent override

* fix(feishu): share ambient proxy transport

* chore(feishu): move release note to pr

---------

Co-authored-by: Peter Steinberger <[email protected]>
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. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M stale Marked as stale due to inactivity status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Feishu channel fails with tenant_access_token error when HTTP proxy is configured

4 participants