fix(serve): stop cdp-mcp-command reading process.env directly - #6562
Conversation
cdp-mcp-command.ts read process.env directly — via a `= process.env` default on resolveCdpMcpCommand and a direct read in isBrowserAutomationMcpAvailable — which trips the serve process.env guard test (process-env-guard.test.ts) and fails CI on main. Thread env through both helpers instead: they now take env explicitly, supplied by the already-allowlisted boundary callers (acp-http, run-qwen-serve, serve-features). Behavior is unchanged.
|
Thanks for the PR! Template: PR body uses custom headings ( Problem: Observed and verified ✅ — Direction: Clear fix — completing the dependency injection that #6472 started. No scope or direction concerns. Size: Not applicable (no core module paths touched). Approach: Minimal and focused — removes the Moving on to code review. 🔍 中文说明感谢贡献! 模板: PR 正文使用了自定义标题( 问题: 已观察并验证 ✅ — 方向: 清晰的修复 — 完成 #6472 开始的依赖注入工作。无范围或方向问题。 规模: 不适用(未触及核心模块路径)。 方案: 最小化且聚焦 — 移除 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewClean, correct implementation. Before/After TestingBefore (main branch — guard test fails)After (this PR — guard test passes, full suite green)Full 中文说明代码审查实现干净、正确。 前后对比测试
— Qwen Code · qwen3.7-max |
|
This is a clean, minimal CI fix. The guard test was broken on One note for the author: the PR body didn't follow the repo's PR template (custom headings instead of the required sections). Not blocking here since the description quality is high, but worth using the template for future contributions. Approving. ✅ 中文说明这是一个干净、最小化的 CI 修复。guard 测试因 #6472 在 提醒作者:PR 正文未遵循仓库的 PR 模板(使用了自定义标题而非必需部分)。此处不阻塞,因为描述质量很高,但建议未来贡献时使用模板。 批准 ✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
Reviewed — no blockers. Suggestion-level recommendations are in the Suggestion summary comment below.
Suggestions — commit
|
yiliang114
left a comment
There was a problem hiding this comment.
Reviewed the env-threading change and the related serve/acp-http call paths. No issues found.
Local verification on faecee7:
- npm -w packages/cli run lint
- npm run build
- npm -w packages/cli run typecheck
- npm -w packages/cli exec vitest run src/serve/process-env-guard.test.ts
- npm -w packages/cli exec -- vitest run src/serve/run-qwen-serve.test.ts -t "normalizes browser MCP env flag|auto-enables only the CDP tunnel|advertises browser automation MCP|does not advertise browser automation MCP|does not enable browser automation MCP"
- npm -w packages/cli exec -- vitest run src/serve/server.test.ts -t "advertises browser automation MCP only when the CDP adapter can connect"
- npm -w packages/cli exec -- vitest run src/serve/acp-http/transport.test.ts -t "does not register chrome-devtools MCP|treats a whitespace-only CDP MCP command|dynamically registers chrome-devtools MCP|passes a custom CDP MCP command"
Problem
packages/cli/src/serve/process-env-guard.test.tsis currently failing onmain. The guard asserts that workspace-scopedserve/acp-bridgecode never readsprocess.envdirectly (outside an explicit allowlist of boundary files).packages/cli/src/serve/cdp-mcp-command.ts— added in #6472 — readsprocess.envdirectly in two spots and was never added to the allowlist, so the guard flags it:This turns the
TestCI check red for every PR branched off currentmain.Fix
Finish the dependency-injection the file was already set up for, so it reads no
process.envat all:resolveCdpMcpCommand(env)— drop the= process.envdefault; takeenvexplicitly.isBrowserAutomationMcpAvailable(opts, env)— takeenvexplicitly and use it for both theQWEN_SERVE_ACP_HTTPcheck and theresolveCdpMcpCommandcall.envis supplied by the three callers, all of which are already in the guard's allowlist and legitimately holdprocess.env:acp-http/index.tsserve/run-qwen-serve.tsserve/server/serve-features.tsBehavior
Unchanged — every
process.envlookup resolves to exactly the same value as before; it's just threaded through a parameter. No allowlist entry needed, becausecdp-mcp-command.tsno longer touchesprocess.env.Related issue
Fixes #6554.