fix(opencode-web): force explicit loopback entries in child no_proxy (issue #75) - #76
Open
linletian wants to merge 1 commit into
Open
fix(opencode-web): force explicit loopback entries in child no_proxy (issue #75)#76linletian wants to merge 1 commit into
linletian wants to merge 1 commit into
Conversation
…(issue #75) opencode embeds the Bun runtime, whose fetch honors HTTP(S)_PROXY but does not match CIDR ranges in no_proxy (e.g. the common 127.0.0.0/8). With a LAN proxy configured, in-process plugin SDK calls to the loopback server were routed through the proxy and failed with 502, surfacing in oh-my-openagent as 'messages.map is not a function' and a 100% task-tool failure in web/serve mode (TUI is unaffected because plugins use in-process fetch there). buildEnv now merges NO_PROXY/no_proxy (both cases) and appends the literal hosts localhost, 127.0.0.1, ::1 so every no_proxy matcher bypasses loopback. No-op without a configured proxy or with a '*' wildcard; existing entries (CIDR included) are preserved; remote LLM provider traffic still goes through the proxy. Verified live: opencode serve + Bun probe returns 502 with CIDR-only no_proxy, and 401/200 (direct) after the fix. Unit tests cover append, merge/dedupe across cases, wildcard, and no-proxy no-op.
Owner
Author
|
CI 备注: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题(#75)
opencode web/serve 入口下 oh-my-openagent 的 task 工具 100% 崩溃:
messages.map is not a function;切到 CLI TUI 即恢复。根因(已在 127.0.0.1 实测复现并验证)
HTTP_PROXY=http://192.168.1.254:6268),no_proxy使用 CIDR 写法127.0.0.0/8。http://127.0.0.1:<port>(opencode 自身服务)的 SDK 调用被送进局域网代理 → 代理无法连接 → 502。normalizeSDKResponse(..., {preferResponseOnMissingData: true})在错误响应下返回非数组对象,下游messages.map直接崩溃。对照实验(opencode 1.18.18 内嵌 Bun 1.3.14 实测):
127.0.0.1后修复
opencode_web.buildEnv合并NO_PROXY/no_proxy(大小写两种)并追加字面 loopback 条目localhost,127.0.0.1,::1:*通配时不动;已有条目(含 CIDR)全部保留、去重。测试
TestWithLoopbackNoProxy(6 个子用例:无代理 no-op / 新建 / CIDR 保留+追加 / 双写合并去重 / 通配跳过 / 幂等)与TestBuildEnv_LoopbackNoProxy(端到端,含代理变量保留断言)。gofmt干净、go test ./...全过、两个二进制构建通过。opencode serve,Bun 探针 401/200(修复前 502)。Closes #75(myworktree 侧)。上游层面另见 issue 评论:Bun 的 no_proxy CIDR 支持、opencode 插件 client 的 loopback 代理绕行、oh-my-openagent 的数组容错。