Repository navigation
fix(extensions): reject http archive URLs with an actionable error instead of attempting a git clone - #12697
Conversation
…stead of attempting a git clone Archive downloads are HTTPS-only (isSupportedArchiveUrl), but isGitUrl also accepts http://, so an archive link served over http:// falls through to the git path and fails with a confusing clone error. Guard the git branch: if an http:// URL points at a supported archive path, throw an actionable error telling the user to re-download from HTTPS. The URL pathname is matched so query strings cannot hide the archive extension.
|
Description rewritten to follow the repository PR template (What this PR does / Why it's needed / Reviewer Test Plan with the Before & After evidence and the OS matrix / Risk & Scope / Linked Issues). Per your notes: Tested on now states macOS/Linux as |
…tations, keep diagnostics Round-1 review follow-ups (all four suggestions): - R1-2: wrap the pathname parse in try/catch so an unparseable http:// URL keeps falling through to the git path (whose error names the source) instead of surfacing a bare TypeError: Invalid URL. Matches the defensive parsing of the sibling helpers in github.ts. - R1-3: the error now also names the git-remote reading — a plain-http Git repository whose name ends in an archive extension is a real (if narrow) case, so the message offers https:// or git@ remotes as the way out instead of implying an archive re-download is the only option. - R1-1: add tests for the uppercase-scheme, fragment-hiding and credential-redaction mutations the review measured as surviving; also pin the unparseable-URL fallthrough and the git-reading wording. - R1-4: ExtensionManager.addSource now rethrows the archive-scheme policy rejection instead of burying it under a misleading No-marketplace-found error; addSource test pins the new behavior. marketplace.test.ts: 41/41 passed locally (Windows 11, Node 22). extensionManager.test.ts: 172 passed, 1 pre-existing Windows symlink-permission (EPERM) failure unrelated to this change.
|
All four suggestions addressed in 90e38ca — thank you for the mutation-testing evidence, it made triage trivial:
Local: |
Real-environment verification: PR #12697 @
|
| Scenario | Result |
|---|---|
Issue shape (A–E): http://…zip, .tar.gz, ?token=1, HTTP://, user:token@ |
Fixed. BASE fails in git clone; row C reproduces the issue's exact could not determine hash algorithm. PR fails immediately with Archive URLs must use https://, 0 requests, credentials printed as ***REDACTED***. |
R1-2 (K1/K2): malformed http://exa mple.com/plugin.zip, port :99999 |
Holds. Output is identical to BASE; no bare Invalid URL. |
R1-4 (L1): extensions sources add http://…zip |
Holds. BASE says "looks like a single extension…"; PR gives the real https reason. https://…zip, http git and garbage input (L2–L4) are unchanged. |
Happy paths (F/G): https://…zip, plain http:// git |
Unchanged; both arms install. |
Upgrade (N): installed from http://…/git/tools.zip on BASE, remote bumped, then extensions update with the PR build |
Safe. It updates 1.0.0 → 1.0.1. update does not call parseInstallSource, so the R1-3 trade-off affects new installs only. |
R1-3 trade-off (H/J1): real git repos at http://…/git/tools.zip and …/bundle.zip |
As the author accepted: BASE installs, PR refuses. |
The daemon and Web Shell install routes are unaffected. They reject any non-https: source with `source` must use https (parseExtensionInstallSource in serve/routes/workspace-extensions.ts) before parseInstallSource runs. I confirmed this by reading the code, not with a live daemon.
3. Tests, lint, mutation
packages/core/src/extension/: 887/887 across 28 files.marketplace.test.tsnow has 41 tests (33 on BASE). ESLint--max-warnings 0, Prettier andtsc --noEmit(core) are all clean on the 4 changed files.- Mutation matrix: 8 of 9 mutants killed. As a control, reverting both source files to BASE turns 7 of the new tests red.
Round-2 findings: runtime evidence
a. R1-3 (fix-induced), the https:// remedy in the message: confirmed, and a measured alternative. Row I shows the https spelling of a git repo named tools.zip being classified as an archive, failing with Failed to download archive … status code 404 on both arms. Besides the bot's "clone it locally" fallback, appending .git also works: rows J2 (http) and O (https) both install on the PR, provided the server resolves the suffix. git http-backend does for bare repos stored as *.git, and GitHub, GitLab and Gitea all accept it. A bare repo stored literally as tools.zip returns 404 for tools.zip.git. Candidate wording for marketplace.ts, checked locally: all 217 tests in the two files stay green, including both Archive URLs must use https:// prefix assertions and the git-clause assertion:
`Re-download the archive from an HTTPS URL — or, if this is a Git ` +
`repository whose name ends in an archive extension, append \`.git\` ` +
`to the URL or use a git@ remote.`,b. R1-4 (fix-induced), the new addSource test goes online: confirmed. Running that single test with NODE_DEBUG=http on the PR arm logs createConnection example.com:80 → sockets example.com:80: 1 1. The same test on BASE opens no socket. I did not reproduce the blackholed-egress timeout.
c. R2-1, the new addSource comment is contradicted at runtime: confirmed. The comment says the tool "never even tried to fetch" a marketplace.json. In row L1 the origin ledger shows the PR's sources add http://…zip making 1 cleartext GET /files/probe-archive-ext.zip → 200 before it rejects, which matches BASE. The fetch itself predates this PR; only the comment is wrong.
d. R2-2, the narrow addSource rethrow is unpinned: confirmed by mutation. Mutant M2, which rethrows every probe error, survives with 217/217 green. Under M2, sources add invalid-format-no-slash would print Install source not found: … instead of No marketplace found at "…". Three lines next to the new assertion kill it (checked: green on the PR, red on M2):
await expect(manager.addSource('invalid-format-no-slash')).rejects.toThrow(
/^No marketplace found at "invalid-format-no-slash"/,
);R2-3 (pathname derivation duplicated from github.ts) is a design point I did not measure.
Before merging (housekeeping)
- The PR body is out of date. It still says "36 tests pass, including 3 new ones"; the file now has 41 (8 new, plus 1 new test in
extensionManager.test.ts). Its "After" message is missing the git clause, and it doesn't mention theaddSourcechange inextensionManager.ts. Risk & Scope still says "No successful install path changes behavior", which rows H/J1 contradict. The author's reply (comment) acknowledged this, but the body was not updated. reviewDecisionis stillCHANGES_REQUESTED. It comes from the triage template gate (review onf3e3c987), filed before the body was rewritten. It clears only when the bot approves on a re-run or a maintainer dismisses it. CI on90e38ca4is otherwise green:Test (ubuntu-latest, Node 22.x),Lint & Staticandreview-prall passed.
Unrelated to this PR and seen on both arms: the successful archive install (row F) prints a Node DEP0005 Buffer() deprecation warning.
中文说明
真实环境验证:PR #12697 @ 90e38ca4
合并参考: 核心修复在真实 CLI 和 TUI 中正确且安全。遇到 http:// 归档 URL 时它会立即失败,给出清晰的报错,且网络请求数为零;https 安装、普通 http git 安装以及已有安装的升级都不受影响。第二轮评审中有两处由修复引入的小问题,值得在合入前再走一小轮:一是报错里的 https:// 补救办法会误导用户,二是新增的单元测试会真实访问外网。其余几项可选。
第二轮机器人评审(review,18:14 UTC,针对
90e38ca4)是在本次实测过程中发布的。与之重合的发现,本报告只补充真实 CLI 和运行时证据,并链接到机器人的原帖,不再重复提出。
环境
- 两个臂都在 macOS 26.6.2 arm64、Node 24.18.1、git 2.55.0 上从源码构建:BASE 是 merge-base
c9a9a8ad,PR 是 head90e38ca4。PR 能干净合入当前main(53afcb69),main 新增的 6 个提交都没有改动packages/core/src/extension/。每个臂执行npm run build && npm run bundle,以node dist/cli.js运行。 - 本地源站自带请求台账。它提供一个真实扩展归档(
probe-archive-ext,.zip与.tar.gz两种),以及通过git http-backend实现的真实 git smart-HTTP(裸仓库probe-git、tools.zip、bundle.zip.git),同时监听http://127.0.0.1:18697和https://127.0.0.1:18698。后者使用本地 CA,通过NODE_EXTRA_CA_CERTS/GIT_SSL_CAINFO传入。 - 每次运行都在
env -i下使用全新的HOME、QWEN_HOME和QWEN_RUNTIME_DIR,不带任何代理变量。TUI 在独立的 tmux socket 中运行。
1. 真实 TUI 中的修复效果
见上方第一张图。BASE 把归档交给了 git clone:源站记录到 GET /files/probe-archive-ext.zip/info/refs?service=git-upload-pack → 404,报错内容只涉及 git。PR 在 parseInstallSource() 内就拒绝了该来源,对源站的请求数为 0,并且报错直接指出了真正的问题:协议。
2. 真实 CLI 矩阵(两个臂)
| 场景 | 结果 |
|---|---|
issue 形态(A–E):http://…zip、.tar.gz、?token=1、HTTP://、user:token@ |
已修复。 BASE 在 git clone 阶段失败,其中 C 行复现了 issue 原文的 could not determine hash algorithm。PR 立即报 Archive URLs must use https://,请求数 0,凭据显示为 ***REDACTED***。 |
R1-2(K1/K2):畸形的 http://exa mple.com/plugin.zip、端口 :99999 |
成立。 输出与 BASE 完全相同,不再出现孤零零的 Invalid URL。 |
R1-4(L1):extensions sources add http://…zip |
成立。 BASE 报「looks like a single extension…」,PR 报真实的 https 原因。https://…zip、http git 和无法识别的输入(L2–L4)行为不变。 |
正常路径(F/G):https://…zip、普通 http:// git |
不变,两个臂都能安装。 |
升级(N):先用 BASE 从 http://…/git/tools.zip 安装,远端提升版本后,用 PR 构建执行 extensions update |
安全。 成功更新 1.0.0 → 1.0.1。update 不经过 parseInstallSource,所以 R1-3 的取舍只影响新安装。 |
R1-3 取舍(H/J1):真实 git 仓库 http://…/git/tools.zip 与 …/bundle.zip |
与作者接受的一致:BASE 能装,PR 拒绝。 |
daemon 和 Web Shell 的安装路由不受影响:它们在调用 parseInstallSource 之前就会以 `source` must use https 拒绝所有非 https: 来源(见 serve/routes/workspace-extensions.ts 的 parseExtensionInstallSource)。这一点是读代码确认的,没有起真实 daemon 验证。
3. 测试、lint 与变异
packages/core/src/extension/:28 个文件共 887/887 通过。marketplace.test.ts现有 41 个用例(BASE 为 33 个)。4 个改动文件的 ESLint--max-warnings 0、Prettier 和 core 的tsc --noEmit全部通过。- 变异矩阵:9 个变异体中 8 个被杀死。作为对照,把两个源文件回退到 BASE 后有 7 个新用例变红。
第二轮发现:运行时证据
a. R1-3(修复引入),报错中的 https:// 补救办法:已实测证实,并给出一个经过实测的替代方案。 I 行显示,名为 tools.zip 的 git 仓库改用 https 写法后被判定为归档,在两个臂上都报 Failed to download archive … status code 404。除了机器人提出的「先在本地 clone」这条退路,在 URL 末尾加 .git 同样可行:J2(http)和 O(https)在 PR 上都能安装成功,前提是服务端能解析这个后缀。git http-backend 在裸仓库以 *.git 存储时可以,GitHub、GitLab、Gitea 也都接受。若裸仓库在磁盘上就叫 tools.zip,请求 tools.zip.git 会得到 404。上方给出的候选文案已在本地验证:两个测试文件共 217 个用例保持全绿,包括两处 Archive URLs must use https:// 前缀断言和针对 git 分句的断言。
b. R1-4(修复引入),新增的 addSource 测试会联网:已证实。 在 PR 臂上用 NODE_DEBUG=http 单独运行该用例,日志中出现 createConnection example.com:80 → sockets example.com:80: 1 1;BASE 上的同名用例不会建立任何 socket。出站流量被黑洞时的超时问题我没有复现。
c. R2-1,新增的 addSource 注释与运行时行为不符:已证实。 注释说工具「never even tried to fetch」marketplace.json。但在 L1 行中,源站台账显示 PR 执行 sources add http://…zip 时,在拒绝之前发出了 1 次明文 GET /files/probe-archive-ext.zip → 200,与 BASE 相同。这次请求本身在本 PR 之前就存在,只是注释写错了。
d. R2-2,addSource 只重抛 https 拒绝的收窄行为没有被钉住:变异实测证实。 变异体 M2(重抛所有探测错误)存活,217/217 全绿。在 M2 下,sources add invalid-format-no-slash 会输出 Install source not found: …,而不是 No marketplace found at "…"。在新断言旁加上方那 3 行即可杀死 M2(已验证:PR 上通过,M2 上变红)。
R2-3(从 github.ts 重复实现 pathname 推导)属于设计层面的问题,本次没有实测。
合并前收尾
- PR 描述已过期。 仍写着「36 tests pass, including 3 new ones」,而该文件现在有 41 个用例(新增 8 个,另有 1 个新用例在
extensionManager.test.ts)。「After」中的报错缺少 git 分句,也没有提到extensionManager.ts中addSource的改动。Risk & Scope 仍写着「No successful install path changes behavior」,与 H/J1 行的实测结果矛盾。作者在回复(comment)中承认了这些,但描述本身没有更新。 reviewDecision仍为CHANGES_REQUESTED。 它来自 triage 的模板门禁(review,提交于f3e3c987),早于描述重写。只有机器人在重新运行后 APPROVE,或维护者 dismiss,才能清除。除此之外,90e38ca4上的 CI 全部通过:Test (ubuntu-latest, Node 22.x)、Lint & Static和review-pr均为绿色。
与本 PR 无关、两个臂都能看到:成功安装归档时(F 行)Node 会打印一条 DEP0005 Buffer() 弃用警告。
…d error, egress-free test Round-2 review follow-ups: - R2-3: export isArchiveShapedUrl from github.ts (single source of truth for the URL-to-pathname archive classification, built on getSupportedArchiveExtension) and collapse the call-site guard to it, so the insecure-scheme rejection can never drift from the archive-vs-git routing it mirrors. Pinned by real-implementation cases in github.test.ts; the marketplace.test.ts stub mirrors the documented semantics. - R2-2: replace the unexported message-prefix contract with a typed InsecureArchiveUrlError thrown by parseInstallSource and matched via instanceof in ExtensionManager.addSource; tighten the addSource test to toBeInstanceOf and add a negative case pinning that non-archive probe failures still produce the No-marketplace-found guidance. - R1-3 (fix-induced): the error no longer recommends an https:// remote for a Git repository whose name ends in an archive extension — an https:// URL with an archive pathname is classified as an archive download first — and now names the git@/SSH remote and the clone-locally fallback instead. The git-reading test asserts the new wording and rejects the old advice. - R1-4 (fix-induced): the addSource test fixture now uses http://127.0.0.1:1 (instant ECONNREFUSED) instead of example.com, so the suite performs no real DNS lookup or outbound HTTP GET. - R2-1: the rethrow comment in addSource now states what actually happens (the marketplace probe has already attempted the fetch; rethrowing changes only the reported reason). Local: marketplace.test.ts 41/41, github.test.ts 149 passed + 9 skipped, extensionManager.test.ts 175 passed + 1 pre-existing Windows symlink-permission (EPERM) failure unrelated to this change (Windows 11, Node 22).
|
Round-2 items addressed in ee80598:
Local (Windows 11, Node 22): marketplace.test.ts 41/41 · github.test.ts 149 passed + 9 skipped · extensionManager.test.ts 175 passed + 1 pre-existing Windows symlink-permission (EPERM) failure unrelated to this change. |
…rrowing, restore the cross-boundary message pin, assert against the real classifier
Round-3 review follow-ups (all four suggestions; no production change needed):\n\n- R3-1: dropped the inert negative assertion and the second parseInstallSource call feeding it — its regex matched only a literal the implementation never produces. The positive assertion above it pins the remedy clause verbatim, so any rewording (including one re-adding an https:// recommendation) still goes red.\n- R3-2: added the discriminating case for the startsWith('http://') conjunct — sso://git.corp/team/tools.zip (archive-shaped pathname, non-http transport isGitUrl admits) stays type: 'git'. Verified: deleting the conjunct turns this test red.\n- R2-3: the mock factory now builds from importOriginal, so isSupportedArchiveUrl and isArchiveShapedUrl are the real implementations (pure URL predicates, nothing to isolate) and the orphaned isSupportedArchivePath stub member is gone; added the missing query-string pins (?token=1) for both real helpers in github.test.ts.\n- R2-2: the addSource test re-adds the message-body assertion (/Archive URLs must use https:\/\/ (got /) alongside toBeInstanceOf, keeping the loopback fixture. Verified: rewrapping the probe failure with a stripped message turns the suite red.\n\nLocal (Windows 11, Node 22): marketplace.test.ts 42/42, github.test.ts 158 passed + 9 skipped, extensionManager.test.ts 175 passed + 1 pre-existing Windows symlink-permission (EPERM) failure unrelated to this change. Both acceptance-criterion mutations confirmed red before reverting.
|
Round-3 items addressed in a97b019 (test-only; no production change needed):\n\n- R3-1 (inert negative assertion): adopted the drop option — the negative assertion and the second |
Real-environment verification, round 2: PR #12697 @
|
| Item | Result on a97b0198 |
|---|---|
The fix (A–E: http://…zip, .tar.gz, ?token=1, HTTP://, user:token@) |
Holds. Immediate Archive URLs must use https://, 0 requests, credentials redacted |
| R1-2, malformed URLs (K1/K2) | Holds. Identical to BASE; isArchiveShapedUrl parses defensively |
R1-4, sources add http://…zip (L1) |
Holds via the typed rethrow; garbage input (L4) still says No marketplace found |
| Round-1 S1 / bot R1-3: https:// advice | Removed. Row I is still a dead end, but the message no longer recommends it |
Round-1 S2 / bot R2-2: widened addSource rethrow |
Now pinned. Mutant M2 is killed |
| Bot R1-4: unit test went online | Fixed. NODE_DEBUG=http shows only createConnection 127.0.0.1:1 |
Bot R2-1: addSource comment |
Fixed. It now says the probe already fetched; row L1 still shows that 1 GET, as the comment describes |
| Bot R2-3: duplicated classifier | Fixed. isArchiveShapedUrl mutants (M6/M7) are killed by both marketplace.test.ts (now on the real github.js) and github.test.ts |
Bot R3-2: http-only narrowing (sso://) |
Pinned. Mutant M3 is killed |
| Upgrade path (N) | Still safe. Installed from http://…/git/tools.zip on BASE, then update with the PR build: 1.0.1 → 1.0.2 |
Happy paths (F/G), sources add https/git (L2/L3) |
Unchanged |
2. New finding: the local-path remedy fails when followed literally
For a git repo whose name ends in .zip, the message now says "…use its git@/SSH remote, or clone it yourself and install from the local path." I followed both remedies in the real CLI and TUI:
- git@/SSH remote: works on both arms. The ssh ledger shows
ssh [email protected] git-upload-pack '…/git/tools.zip'. - Clone and install locally: fails for the natural clone.
git clone http://…/git/tools.zipcreates./tools.zip/. Thenextensions install ./tools.zip, or the absolute path, fails withExtension archive could not be extracted. Make sure it is a valid .zip or .tar.gz file. EISDIR: illegal operation on a directory. The cause is thatinstallExtensionchooses archive extraction by name (installMetadata.type === 'local' && isSupportedArchivePath(source),extensionManager.ts:2387). This behaviour predates the PR (BASE fails the same way), but the message now sends users there. Cloning into a directory with a different name (git clone … tools-src) installs fine.
Candidate wording, checked locally: all 376 tests pass with the pin updated, and the message renders as intended:
`repository whose name ends in an archive extension, use its ` +
`git@/SSH remote, or clone it into a directory whose name does not end ` +
`in .zip or .tar.gz and install from that local path.`,Update the pin in marketplace.test.ts to match, anchored at the end (…install from that local path\.$/). The anchor also closes the one surviving mutant (M10, §4).
A code fix (extract only when the local source is a file) would make the original wording true. It has to cover two sites, installExtension (extensionManager.ts:2387) and checkForExtensionUpdate (github.ts:581), so it is probably better as a follow-up.
3. Real CLI matrix (both arms)
4. Tests, lint, mutation
packages/core/src/extension/: 889/889 across 28 files. The three touched test files: 376/376. ESLint--max-warnings 0, Prettier andtsc --noEmit(core) are clean on all 6 changed files.- Mutation matrix: 11 of 12 mutants killed. Round 1's survivor (M2) is now killed. The one survivor is M10: appending "You can also retry the same URL over https://." to the message stays green. This is the gap the bot flagged as R3-1.
a97b0198dropped that negative assertion on the grounds that the positive pin covers it, but an unanchored substring pin doesn't catch appended text. With the §2 wording and the end-anchored pin, M10 is killed.
Before merging
Lint & Staticis red only at "Check lint gate freshness". Onmain,c7c6def8(test(managed-agent): add Hosted no-tool process gates #12733) edited.github/workflows/ci.ymlafter this branch's merge-base, so the branch needsgit merge origin/main(not a rebase) and a push. The code itself is lint-clean locally.Integration Tests (no-AK)passed. When this was written,Test (ubuntu-latest)and the round-4review-prwere still pending ona97b0198.- The PR body is still unchanged since round 1. It still reports "36 tests pass, including 3 new ones", shows the original message, and says "No successful install path changes behavior". It doesn't mention the
addSource, typed-error orgithub.tschanges. reviewDecisionis stillCHANGES_REQUESTEDfrom the triage template gate (review). Only a bot approval or a maintainer dismissal clears it.
中文说明
真实环境验证第 2 轮:PR #12697 @ a97b0198
接续第 1 轮(90e38ca4)。本轮复验两个新提交:ee805983(类型化的 InsecureArchiveUrlError、共用的 isArchiveShapedUrl、改写报错文案、离线化测试)和 a97b0198(仅改测试)。
合并参考: 修复在功能上已可合入。第 1 轮和机器人第 2、3 轮中凡是我能实测的项目,在新 head 上都成立。新报错文案还剩一个问题:它给出的两个补救办法中,本地路径那条照字面执行会失败。修复只需改两行文案并同步更新测试钉子(见 §2)。另外,CI 的 Lint & Static 变红只是因为分支需要合入 origin/main;PR 描述也仍未更新。
环境
PR 臂在 a97b0198 上从源码重新构建(npm run build && npm run bundle)。BASE 仍是 merge-base c9a9a8ad,输出与第 1 轮逐字节相同。沿用第 1 轮的环境:本地源站在 http/https 上提供真实扩展归档和 git http-backend,并记录请求台账;每次运行在 env -i 下使用全新的 HOME/QWEN_HOME/QWEN_RUNTIME_DIR;TUI 在独立的 tmux socket 中运行。本轮新增两样:用真实的 git clone 测试本地路径补救办法;用假 ssh(GIT_SSH_COMMAND,记录调用并在本地执行 git-upload-pack)测试 git@ 补救办法。
1. 之前各项在 a97b0198 上的状态
| 项目 | a97b0198 上的结果 |
|---|---|
修复本身(A–E:http://…zip、.tar.gz、?token=1、HTTP://、user:token@) |
成立。 立即报 Archive URLs must use https://,请求数 0,凭据已打码 |
| R1-2,畸形 URL(K1/K2) | 成立。 与 BASE 完全相同;isArchiveShapedUrl 解析时做了防护 |
R1-4,sources add http://…zip(L1) |
通过类型化重抛成立;无法识别的输入(L4)仍报 No marketplace found |
| 第 1 轮 S1 / 机器人 R1-3:建议改用 https:// | 已删除。 I 行仍是死路,但报错已不再推荐它 |
第 1 轮 S2 / 机器人 R2-2:addSource 重抛被放宽 |
已被测试钉住。 变异体 M2 被杀死 |
| 机器人 R1-4:单测会联网 | 已修复。 NODE_DEBUG=http 下只看到 createConnection 127.0.0.1:1 |
机器人 R2-1:addSource 注释 |
已修复。 注释现在说明探测已经发过请求;L1 行仍记录到那 1 次 GET,与注释描述一致 |
| 机器人 R2-3:分类逻辑重复实现 | 已修复。 isArchiveShapedUrl 的变异体(M6/M7)被 marketplace.test.ts(现在用的是真实 github.js)和 github.test.ts 同时杀死 |
机器人 R3-2:只针对 http 的收窄(sso://) |
已被测试钉住。 变异体 M3 被杀死 |
| 升级路径(N) | 仍然安全。 先用 BASE 从 http://…/git/tools.zip 安装,再用 PR 构建执行 update:1.0.1 → 1.0.2 |
正常路径(F/G)、sources add 的 https 与 git 来源(L2/L3) |
不变 |
2. 新发现:本地路径补救办法照字面执行会失败
对于名称以 .zip 结尾的 git 仓库,报错现在写的是「…use its git@/SSH remote, or clone it yourself and install from the local path」。我在真实 CLI 和 TUI 中把两条补救办法都执行了一遍:
- git@/SSH 远端:可行,两个臂都能安装。ssh 台账记录到
ssh [email protected] git-upload-pack '…/git/tools.zip'。 - 自己 clone 后从本地安装:按最自然的做法会失败。
git clone http://…/git/tools.zip会创建./tools.zip/目录,之后执行extensions install ./tools.zip(或绝对路径)报Extension archive could not be extracted. Make sure it is a valid .zip or .tar.gz file. EISDIR: illegal operation on a directory。原因是installExtension按名称决定是否解压归档(installMetadata.type === 'local' && isSupportedArchivePath(source),extensionManager.ts:2387)。这一行为早于本 PR(BASE 上同样失败),但现在的报错会把用户引到这里。clone 到其他名字的目录(git clone … tools-src)则可以正常安装。
上方的候选文案已在本地验证:同步更新钉子后 376 个用例全部通过,报错渲染符合预期。marketplace.test.ts 里的钉子要随之更新,并在末尾加锚点(…install from that local path\.$/),这样也能堵住唯一存活的变异体(M10,见 §4)。
另一种做法是改代码:只有本地来源是文件时才按归档解压,这样原文案就成立了。但需要同时改两处,installExtension(extensionManager.ts:2387)和 checkForExtensionUpdate(github.ts:581),更适合作为后续 PR。
3. 真实 CLI 矩阵(两个臂)
见上方矩阵图。
4. 测试、lint 与变异
packages/core/src/extension/:28 个文件共 889/889 通过;本 PR 涉及的三个测试文件 376/376。6 个改动文件的 ESLint--max-warnings 0、Prettier 和 core 的tsc --noEmit全部通过。- 变异矩阵:12 个变异体中 11 个被杀死。第 1 轮存活的 M2 现在被杀死了。唯一存活的是 M10:在报错末尾追加「You can also retry the same URL over https://.」时测试仍全绿。这正是机器人 R3-1 指出的缺口。
a97b0198删掉了那条反向断言,理由是正向钉子已经覆盖;但不带锚点的子串钉子抓不到追加的文字。改用 §2 的文案并在钉子末尾加锚点后,M10 被杀死。
合并前
Lint & Static只红在「Check lint gate freshness」这一步。 main 上的c7c6def8(test(managed-agent): add Hosted no-tool process gates #12733)在本分支的 merge-base 之后修改了.github/workflows/ci.yml,所以分支需要执行git merge origin/main(不要 rebase)并推送。代码本身在本地 lint 全部通过。Integration Tests (no-AK)已通过。撰写本报告时,a97b0198上的Test (ubuntu-latest)和第 4 轮review-pr仍在进行。- PR 描述自第 1 轮以来没有任何改动。 仍写着「36 tests pass, including 3 new ones」,展示的还是最初的报错,也仍说「No successful install path changes behavior」;
addSource、类型化错误和github.ts的改动都没有提及。 reviewDecision仍为CHANGES_REQUESTED,来自 triage 的模板门禁(review)。只有机器人批准或维护者 dismiss 才能清除。
… literally; pin the message end-to-end Real-environment verification round 2 found that the local-path remedy in the InsecureArchiveUrlError message fails when followed literally: git clone http://host/git/tools.zip creates ./tools.zip/, and installExtension chooses archive extraction by name (installMetadata.type === 'local' && isSupportedArchivePath(source)), so installing from a directory named *.zip fails with EISDIR. This behavior predates the PR, but the message now sends users there.\n\nThe remedy wording now says to clone into a directory whose name does not end in .zip or .tar.gz (the git@/SSH remedy was verified to work as-is). A code fix (extract only when the local source is a file, covering installExtension and checkForExtensionUpdate) would make the original wording true and is better suited to a follow-up.\n\nThe marketplace.test.ts pin is upgraded from a substring-with-end-anchor to a full-string anchor (^...$): adversarial replay showed an end-anchored pin still lets an https:// recommendation be inserted mid-message while every test stays green; the full-string anchor kills appends (mutation M10), mid-message insertions, and any rewording.\n\nLocal (Windows 11, Node 22): marketplace.test.ts 42/42; the three touched suites 376 of 377 with the one pre-existing Windows symlink-permission (EPERM) failure unrelated to this change.
|
Thank you for the round-2 real-environment verification — the §2 finding (local-path remedy fails when followed literally) was exactly the kind of check this message needed. All items addressed in
Adversarial review I ran on the updated message pin (all mutations applied, tested, then reverted):
Because the mid-message insertion survived the end-anchored pin, the assertion in One residual disclosed rather than fixed: the message says the directory name must not end in ".zip or .tar.gz", but Local (Windows 11, Node 22): marketplace.test.ts 42/42 · github.test.ts 158 passed + 9 skipped · extensionManager.test.ts 175 passed + 1 pre-existing Windows symlink-permission (EPERM) failure unrelated to this change. |
Real-environment verification, round 3: PR #12697 @
|
|
Thank you for the round-3 real-environment verification — great to see all 14 mutants killed and both remedies installing when followed literally on both arms. No code change this round; the PR body was updated to address all three non-blocking items:
Adversarial verification of the updated claims
Head remains 中文说明感谢第 3 轮真实环境验证——14 个变异体全部被杀死、两条补救办法照字面执行都能在两个臂上安装,非常好。 本轮没有代码改动,只更新了 PR 描述,落实全部三项非阻塞意见:
对抗性核实:A1 从源码独立复推 §3 更正(属实);A2 攻击 follow-up 范围声明——确认更新路径同样走按名解压(github.ts:565 → head 仍为 |
|
@qwen-code /triage |
…s-p0-p8 Brings in main through 939b4db: QwenLM#12697 (http archive URLs rejected with an actionable error), QwenLM#12741 (batch task records that list cannot read) and QwenLM#12652 (scrollbar gutter in the collapsed sidebar rail). The merge is clean.









What this PR does
When a user installs an extension from an archive URL served over plain
http://,parseInstallSource()now rejects it immediately with a typedInsecureArchiveUrlError(exported frommarketplace.ts) carrying an actionable message:Previously the request was misrouted into the git-clone path and failed downstream with a confusing
Failed to clone Git repository from <...>.ziperror. Plainhttp://Git URLs and non-http transportsisGitUrladmits (e.g.sso://) keep working exactly as before. Two supporting changes:github.tsexportsisArchiveShapedUrl(built ongetSupportedArchiveExtension), so the insecure-scheme rejection shares its URL→pathname classification with the archive-vs-git routing and cannot drift from it.ExtensionManager.addSourcerethrows the policy rejection instead of burying it underNo marketplace found at ...when the input is an insecure archive URL.Why it's needed
Archive downloads are HTTPS-only by design:
isSupportedArchiveUrl()accepts onlyhttps:URLs. ButisGitUrl()acceptshttp://, so an archive link overhttp://skips the archive branch, gets classified as a git source, and fails downstream with an error that names git and says nothing about the real problem (the scheme). Reproduced on the 0.24.5 npm build, Windows 11:With this change the same command fails fast with the message above.
Reviewer Test Plan
How to verify
Run the extension marketplace unit tests:
npm run test --workspace=@qwen-code/qwen-code -- src/extension/marketplace.test.ts(or the vitest equivalent). Expected: 42 tests pass in that file; the three touched suites total 376 passing. The message body is pinned end-to-end (^...$) inmarketplace.test.ts, and thesso://non-http-transport case, the credential-redaction case, and the unparseable-URL fallthrough each have their own discriminating tests.Evidence (Before & After)
Before (0.24.5 npm build, real run):
After (real CLI run during independent real-environment verification, and asserted by the unit suite):
The git@/SSH remedy was verified end-to-end against a fake ssh serving
git-upload-pack; the local-path remedy wording reflects the measuredEISDIRbehavior of installing from a directory named*.zip(pre-existing on main, see Risk & Scope).Tested on
Windows 11 / Node 22: differential repros on 0.22.3 and 0.24.5 npm builds plus the unit suites. macOS 26.6.2 arm64: all three rounds of the independent real-environment verification (real
git http-backend, request ledger, TUI in tmux) ran there, covering the CLI/TUI matrix, the upgrade path, and both remedies. Linux not exercised; this is a URL-classification path with no platform-specific logic.Environment (optional)
Local
vitest runon Windows 11, Node 22. Differential repros used the published npm builds (0.22.3 / 0.24.5) against a local HTTPS server serving a test extension archive.Risk & Scope
http://archive URLs are now rejected outright. No working use case is broken — the same input already failed with the confusing git-clone error, because the archive downloader is HTTPS-only. The one narrow exception (a git repository whose name ends in an archive extension, served over http) keeps two working remedies: the git@/SSH remote, and cloning into a directory not named*.zip/*.tar.gz.installExtensionchooses archive extraction by name for local sources, so installing from a directory named*.zipfails withEISDIR(extensionManager.ts:2387, same on main). The same case-sensitivity mismatch surfaces independently of directories: archive routing matches extensions case-insensitively (getSupportedArchiveExtensionFromPathnamelowercases the pathname, github.ts:86-102) while the extraction dispatch is case-sensitive (extractFile, github.ts:1353/1371), so anhttps://URL or a local file ending in.ZIPfails withUnsupported file extension for extraction. A follow-up PR should extract only regular files and dispatch on the lowercased extension, coveringinstallExtensionandcheckForExtensionUpdate— that would close theEISDIRcase and the*.ZIPmismatch together.http://archive case changes from a late, confusing git error to an immediate, typed rejection. No other successful install path changes behavior — with one narrow exception spelled out in the Risk section above: a git repository whose name ends in an archive extension, served overhttp://, previously installed successfully and is now refused (the message offers two working remedies for it).Linked Issues
Refs #10742, #10741
中文说明
这个 PR 做了什么
当用户通过纯
http://的归档 URL 安装扩展时,parseInstallSource()现在会立即拒绝,并抛出从marketplace.ts导出的类型化错误InsecureArchiveUrlError,附可操作的错误信息:此前请求会被误路由到 git clone 路径,之后才以令人困惑的
Failed to clone Git repository from <...>.zip错误失败。普通http://Git URL 以及isGitUrl接受的其他非 http 传输方式(如sso://)行为完全不变。两项配套修改:github.ts导出isArchiveShapedUrl(基于getSupportedArchiveExtension),使不安全协议拒绝与归档/git 分类共享同一套 URL→pathname 判定,不会漂移。ExtensionManager.addSource在输入是不安全归档 URL 时重新抛出策略拒绝,而不是用No marketplace found at ...掩盖真实原因。为什么需要
归档下载在设计上仅支持 HTTPS:
isSupportedArchiveUrl()只接受https:URL。但isGitUrl()同时接受http://,因此http://的归档链接会跳过归档分支、被归类为 git 来源,然后在下游失败,报错只提 git、完全没提到真正的问题(协议方案)。在 0.24.5 npm 版本(Windows 11)上复现:修改后,同样的命令会快速失败,并给出上面的错误信息。
审阅者测试计划
如何验证
运行扩展市场单元测试:
npm run test --workspace=@qwen-code/qwen-code -- src/extension/marketplace.test.ts(或等效的 vitest 命令)。预期:该文件 42 个测试全部通过;三个涉及的套件合计 376 个通过。错误消息在marketplace.test.ts中被全串锚定(^...$)钉住;sso://非 http 传输、凭据脱敏、不可解析 URL 回落各有独立的判别测试。证据(修改前与修改后)
修改前(0.24.5 npm 版本,真实运行):
修改后(独立真实环境验证中的真实 CLI 运行,同时由单元测试断言):
git@/SSH 补救办法已用假 ssh(本地
git-upload-pack)端到端验证;本地路径补救措辞反映了从*.zip命名目录安装时的实测EISDIR行为(main 上预存,见风险与范围)。测试平台
Windows 11 / Node 22:在 0.22.3 与 0.24.5 npm 版本上做了差分复现,并完整运行单元套件。macOS 26.6.2 arm64:独立真实环境验证(真实
git http-backend、请求台账、tmux 中的 TUI)的全部三轮都在该平台运行,覆盖 CLI/TUI 矩阵、升级路径和两条补救办法。Linux 未运行;这是 URL 分类路径,没有平台特定逻辑。环境(可选)
Windows 11、Node 22 上本地
vitest run。差分复现使用已发布的 npm 版本(0.22.3 / 0.24.5),配合本地 HTTPS 服务器提供测试扩展归档。风险与范围
http://归档 URL 现在被直接拒绝。没有破坏任何可用的场景 —— 相同输入此前本来就会以令人困惑的 git clone 错误失败,因为归档下载器仅支持 HTTPS。唯一的窄例外(名字以归档扩展名结尾、经 http 提供的 git 仓库)保留两条可行的补救:git@/SSH 远端,以及 clone 到名字不以*.zip/*.tar.gz结尾的目录。installExtension对本地来源按名称选择归档解压,因此从名为*.zip的目录安装会以EISDIR失败(extensionManager.ts:2387,main 上相同)。同一个大小写不一致还会独立于目录出现:归档路由对扩展名不区分大小写(getSupportedArchiveExtensionFromPathname会把 pathname 转小写,github.ts:86-102),而解压分派区分大小写(extractFile,github.ts:1353/1371),因此以.ZIP结尾的https://URL 或本地文件会报Unsupported file extension for extraction。后续 PR 应改为只解压普通文件、并按小写扩展名分派,覆盖installExtension与checkForExtensionUpdate—— 这样可以把EISDIR场景和*.ZIP不一致一起解决。http://归档场景从滞后的、令人困惑的 git 错误变为立即的、类型化的拒绝。其余任何成功的安装路径行为均未改变 —— 唯一的窄例外已在上方风险条目中写明:名字以归档扩展名结尾、经http://提供的 git 仓库此前能安装成功,现在会被拒绝(报错信息为它提供了两条可行的补救办法)。关联 Issue
Refs #10742, #10741