Skip to content

fix: 禁用 axios 自动代理读取,修复 HTTP_PROXY 导致 URL 拼接错误 (#493)#508

Open
easonlh wants to merge 2 commits into
larksuite:mainfrom
easonlh:fix/http-proxy-url-concat
Open

fix: 禁用 axios 自动代理读取,修复 HTTP_PROXY 导致 URL 拼接错误 (#493)#508
easonlh wants to merge 2 commits into
larksuite:mainfrom
easonlh:fix/http-proxy-url-concat

Conversation

@easonlh
Copy link
Copy Markdown
Contributor

@easonlh easonlh commented May 13, 2026

Summary

  • 禁用 Lark SDK 默认 axios 实例的自动代理读取(proxy: false),修复当系统设置 http_proxy 环境变量时 API URL 被错误拼接的问题
  • 代理路由由 OpenClaw 核心的 global-agent 统一管理,Lark SDK 不应自行处理代理

Root Cause

@larksuiteoapi/node-sdk 使用 axios.create() 作为默认 HTTP 客户端。Axios v1.x 会自动读取 HTTP_PROXY/HTTPS_PROXY 环境变量并应用代理,与 OpenClaw 核心的 global-agent 产生冲突,导致 URL 被拼接为类似 http://127.0.0.1:7890https://open.feishu.cn/xxxx 的无效格式。

Fix

src/core/lark-client.ts 中,于 Lark.defaultHttpInstance 上显式设置 proxy: false,仅增加 1 行代码。

Test plan

  • pnpm test — 271 tests passed
  • pnpm lint — 0 errors
  • 手动验证:设置 http_proxy 环境变量后,飞书 API 请求正常

Fixes #493

Copy link
Copy Markdown
Collaborator

@evandance evandance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxy fix itself looks correct and minimal — proxy: false on Lark.defaultHttpInstance.defaults is the right way to disable axios' auto-reading of HTTP_PROXY/HTTPS_PROXY, and the comment explaining global-agent ownership is good context.

The PR currently bundles two independent changes though: the proxy fix (src/core/lark-client.ts) and the Schema 2 operator.user_id fallback from #505 (src/channel/interactive-dispatch.ts, commit 8988258), because this branch is opened on top of #505 rather than main. Each fix is a separate concern with separate review state — #505 still needs a codebase sweep before it can land — so they should travel independently.

Could you rebase #508 onto main so it carries only the proxy commit (7b6be30)? The proxy fix can then land cleanly without being coupled to #505's progress.

@evandance evandance added bug Something isn't working core src/core/ — accounts, owner-policy, token, security, config changes requested Need do changes labels May 14, 2026
@easonlh easonlh force-pushed the fix/http-proxy-url-concat branch from 7b6be30 to 94579ed Compare May 15, 2026 00:18
@easonlh
Copy link
Copy Markdown
Contributor Author

easonlh commented May 15, 2026

@evandance 已经重新rebase,只剩 proxy 一个 commit。

@easonlh easonlh requested a review from evandance May 15, 2026 00:40
Copy link
Copy Markdown
Collaborator

@evandance evandance left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the rebase — the branch is now clean (proxy fix + a small drive-by converting three lark-client.ts comments from Chinese to English, which aligns with the repo's English-comments convention).

One adjustment before this is mergeable: the commit messages currently carry a Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> trailer. That doesn't match the repo's standard commit-message style — none of the recent merged commits, including AI-assisted contributions from other contributors, include Co-Authored-By trailers. Please amend both commits to drop the trailer and force-push.

easonlh added 2 commits May 15, 2026 20:55
当系统设置 http_proxy 环境变量时,axios v1.x 自动读取并应用代理,
与 OpenClaw 核心的 global-agent 冲突,导致 API URL 被错误拼接
(如 http://127.0.0.1:7890https://open.feishu.cn/xxxx)。

在 Lark.defaultHttpInstance 上显式设置 proxy: false,禁用 axios
的自动代理读取,代理路由由 OpenClaw 核心的 global-agent 统一管理。

Fixes larksuite#493
@easonlh easonlh force-pushed the fix/http-proxy-url-concat branch from 62bea18 to a27ea85 Compare May 15, 2026 12:56
@easonlh easonlh requested a review from evandance May 15, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working changes requested Need do changes core src/core/ — accounts, owner-policy, token, security, config

Projects

None yet

Development

Successfully merging this pull request may close these issues.

开启http_proxy,apiurl会拼接http_proxy的值,导致报400错误,比如http://127.0.0.1:7890https://open.feishu.cn/xxxx

2 participants