fix(cli): reject unsupported extension scopes - #5714
Conversation
ae049c4 to
2ad4484
Compare
|
@qwen-code /triage |
|
Thanks for the PR, @tt-a1i! Template looks good ✓ — all required sections present, bilingual, linked to #5712. On direction: this is a straightforward bug fix for a real issue. The On approach: the scope feels tight and correct. Extracting Moving on to code review. 🔍 中文说明感谢贡献,@tt-a1i! 模板完整 ✓ — 所有必填部分齐全,双语,已关联 #5712。 方向:这是一个直接的 bug 修复,解决真实问题。 方案:范围紧凑且正确。将 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
2a. Code ReviewIndependent proposal: I would extract a shared scope-validation function (e.g. PR matches this exactly. The implementation is clean — Reuse check: The new function is the right level of abstraction for this use case — no existing shared validator was being missed. One observation (not a blocker): No critical blockers or AGENTS.md violations found. ✅ 2b. Real-Scenario TestingBefore (installed
|
ReflectionThis PR is what a good bug fix looks like: a real problem, a minimal change, and clean execution. The bug is concrete — The implementation matches what I'd have proposed independently. The All 29 unit tests pass. The standalone logic verification confirms all unsupported scopes are rejected. The installed CLI (v0.18.5) clearly reproduces the bug. One minor note: I couldn't run a full before/after with The pre-existing enable/disable error handling asymmetry ( Verdict: approve. Ship it. ✅ 中文说明反思这个 PR 是一个优秀 bug 修复的典范:真实问题、最小改动、干净实现。 Bug 是具体的—— 实现与我独立提出的方案完全一致。 29 个单元测试全部通过。独立逻辑验证确认所有不支持的 scope 都被拒绝。已安装的 CLI(v0.18.5)清楚复现了 bug。 一个小备注:由于 CI 环境中预存的 enable/disable 的错误处理不对称( 结论:批准。 可以合入。✅ — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
✅ Local verification report (maintainer)Built and tested this PR locally to confirm the fix before merge. Environment
Results
Mutation test (the key evidence). I reverted the three source files (
The 12 unrelated tests stay green. Both fixes are genuinely guarded. Correctness review
Note on the documented typecheck failure. As with this author's other PRs, the Minor / non-blocking observation. In both handlers Verdict: LGTM. Both fixes correct and mutation-verified, type/lint/format clean. Safe to merge from my side — the documented "typecheck failure" is an author-local artifact, not a blocker. 🇨🇳 中文版✅ 本地验证报告(维护者)合并前在本地构建并测试了本 PR 以确认修复。 环境
结果
变异测试(关键证据)。 我把三个源文件(
12 个无关测试保持绿色。两个修复都被测试真正挡住了。 正确性审查
关于记录的 typecheck 失败。 和这位作者的其它 PR 一样, 次要 / 非阻塞观察。 两个 handler 都在校验 scope 之前就 结论:LGTM。 两个修复都正确且经变异测试验证,类型/lint/格式干净。从我这边看可以安全合并 —— 记录的「typecheck 失败」是作者本地环境产物,不是阻塞项。 |
What this PR does
This PR narrows
qwen extensions enable --scopeandqwen extensions disable --scopeto the scopes that extension enablement actually supports:userandworkspace.It also awaits the async extension manager enable/disable calls so rejected manager failures are handled by the existing command error paths instead of printing success before an unhandled rejection.
Why it's needed
The commands previously validated
--scopeagainst everySettingScopevalue, includingsystemandsystemdefaults. The handlers only special-casedworkspace, so any other accepted scope was sent to the extension manager asUser. That made commands likeqwen extensions enable my-extension --scope=systemreport success forsystemwhile writing user-scope enablement config.Rejecting unsupported scopes at command validation and handler level keeps CLI output aligned with the actual persisted scope.
Reviewer Test Plan
How to verify
Run the focused extension command tests and confirm that
system/systemdefaultsare rejected for both enable and disable, whileuserandworkspacecontinue to pass.Evidence (Before & After)
Before:
--scope=systemand--scope=systemdefaultspassed yargs validation and were mapped to user-scope manager calls.After: those unsupported scopes fail validation with
Invalid scope, and direct handler calls do not invoke the manager with user scope. Async manager rejections are also covered by tests using rejected promises.Tested on
Environment (optional)
Local workspace tests on macOS with the repository npm workspace setup.
Commands run:
npm test --workspace=packages/cli -- commands/extensions/enable.test.ts commands/extensions/disable.test.ts --coverage.enabled=false npx prettier --check packages/cli/src/commands/extensions/utils.ts packages/cli/src/commands/extensions/enable.ts packages/cli/src/commands/extensions/disable.ts packages/cli/src/commands/extensions/enable.test.ts packages/cli/src/commands/extensions/disable.test.ts npx eslint packages/cli/src/commands/extensions/utils.ts packages/cli/src/commands/extensions/enable.ts packages/cli/src/commands/extensions/disable.ts packages/cli/src/commands/extensions/enable.test.ts packages/cli/src/commands/extensions/disable.test.ts git diff --checkAlso run:
This currently fails on unrelated existing
BaseTextInput.tsx/inktype resolution errors:Sub-agent review: initial async-error finding was addressed; follow-up review found no blocking issues.
Risk & Scope
systemorsystemdefaultsnow get a validation error instead of silently writing user-scope enablement config.Linked Issues
Fixes #5712
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.
中文说明
What this PR does
这个 PR 将
qwen extensions enable --scope和qwen extensions disable --scope收窄到 extension enablement 实际支持的范围:user和workspace。同时,handler 现在会
awaitasync 的 extension manager enable/disable 调用,让 manager 的 rejected failure 进入现有命令错误路径,而不是先打印成功再出现未处理 rejection。Why it's needed
这些命令之前会用所有
SettingScope值校验--scope,包括system和systemdefaults。但 handler 只特殊处理workspace,其他已通过校验的 scope 都会被当成User传给 extension manager。这样qwen extensions enable my-extension --scope=system会报告 system scope 成功,但实际写入 user-scope enablement config。在命令校验和 handler 层拒绝不支持的 scope,可以让 CLI 输出和真实持久化 scope 保持一致。
Reviewer Test Plan
How to verify
运行 focused extension command tests,确认 enable 和 disable 都会拒绝
system/systemdefaults,同时user和workspace仍然通过。Evidence (Before & After)
Before:
--scope=system和--scope=systemdefaults可以通过 yargs 校验,并被映射成 user-scope manager 调用。After: 这些不支持的 scope 会以
Invalid scope校验失败,直接调用 handler 时也不会再用 user scope 调 manager。async manager rejection 也用 rejected promise 测试覆盖。Tested on
Environment (optional)
在 macOS 上使用仓库 npm workspace 进行本地测试。
已运行命令:
npm test --workspace=packages/cli -- commands/extensions/enable.test.ts commands/extensions/disable.test.ts --coverage.enabled=false npx prettier --check packages/cli/src/commands/extensions/utils.ts packages/cli/src/commands/extensions/enable.ts packages/cli/src/commands/extensions/disable.ts packages/cli/src/commands/extensions/enable.test.ts packages/cli/src/commands/extensions/disable.test.ts npx eslint packages/cli/src/commands/extensions/utils.ts packages/cli/src/commands/extensions/enable.ts packages/cli/src/commands/extensions/disable.ts packages/cli/src/commands/extensions/enable.test.ts packages/cli/src/commands/extensions/disable.test.ts git diff --check也运行了:
该命令目前因既有且无关的
BaseTextInput.tsx/ink类型解析错误失败:子代理审查:首次审查发现的 async error handling 问题已修复;复核未发现阻塞问题。
Risk & Scope
system或systemdefaults的用户现在会收到校验错误,而不是静默写入 user-scope enablement config。Linked Issues
Fixes #5712
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.