Skip to content

DWSH-49: fix false success when installer skills are missing - #1547

Merged
dingtalk-dws-reviewer-router[bot] merged 1 commit into
mainfrom
codex/dwsh-49-installer-skills-fail-closed
Oct 22, 2026
Merged

dingtalk-dws-reviewer-router[bot] merged 1 commit into
mainfrom
codex/dwsh-49-installer-skills-fail-closed

Conversation

@haofeng0705

Copy link
Copy Markdown
Collaborator

Summary

When a checksummed release archive contains no usable skills for the selected mode and no local checkout is available, both installers currently return from skills installation and still print Installation complete!.

  • Throw a terminating PowerShell error for this branch and for a missing local mono skills directory, preserving the existing finally cleanup.
  • Fail through the shell installer's existing err helper for the equivalent release-archive branch.
  • Add regression tests using local archives and HTTP stubs, covering mono selection with a multi-only archive, multi selection with no skills, and the PowerShell local-directory failure.
  • Add a user-visible release fragment.

The download-failure branch already fails; this change addresses the separate missing-skill-content branch described in #779. PowerShell uses throw rather than the Write-Err helper's exit, to avoid closing an interactive irm | iex session.

Closes #779.

Risk tier

  • High-risk under the repository's installer classification.

The implementation change is limited to three failure branches. Automation that previously accepted these false-success results will now receive failures. A full install may already have installed the CLI binary before skills installation fails.

Verification

  • Release fragment added: .changes/779-installer-skills-fail-closed.md.

  • Static comparison against main@87d23e5cf1b181e33aa302b0502d1af2922cea79: both original installer blobs retain the affected branches.

  • Regression tests added and formatted with gofmt; tests have not been run locally.

  • Targeted test command:

    DWS_PACKAGE_VERSION=0.0.0-test go test ./test/scripts -run '^TestInstall(Script|PowerShell)MissingSkillsFailsWithoutSuccessBanner$' -count=1
  • Native Windows PowerShell 5.1 execution and the existing successful-install tests remain required verification. The PowerShell regression test prefers Windows PowerShell on Windows and skips when no supported PowerShell executable is installed.

  • Full suite, packaging verification, builds and policy checks have not been run.

  • No CLI command paths, flags, generated artifacts or workflows change.

Notes

Proxy routing, README expansion and broader interactive exit behavior are outside this patch.

Stop both installers from reporting success when release skills are unusable and local fallback is unavailable. Add isolated regression coverage for the failure branches.

Refs #779

@typefield typefield left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CR 结论:改动正确,建议合并(等 CI 全绿)

重点核对

1. 失败时能否中断成功提示 —— 能,两端都成立

  • shell:err() 是 printf + exit 1(install.sh:52),在 install_skills 缺失分支直接终止进程,main 里的 🎉 Installation complete! 不会执行;trap EXIT 仍会清理 tmpdir。
  • PowerShell:顶层 main 无 try/catch,throw 作为脚本终止性错误直接跳过 banner。Install-Skills 内新增的 throw 位于 try/finally 中,finally 的 $tmpDir 清理保留完好;Install-SkillsLocal 的 throw 无论被 main 直接调用还是经 Install-Skills 的 try/finally,都不会被吞。

2. PowerShell 用 throw 而非 Write-Err —— 理由成立

Write-Err 里是 exit 1,irm | iex 场景会杀掉用户的交互会话;throw 只终止脚本块。同函数内下载失败分支仍用 Write-Err(irm|iex 下会关会话),属于已知不一致,PR notes 已声明范围外,可接受,建议后续统一。

3. 测试覆盖 —— 有效且真实(已代跑)

PR 自述"测试未在本地运行",我实际执行了目标测试命令:

PR 分支:  5/5 PASS(shell mono/multi + ps1 mono/multi/local-missing;本机有 pwsh,PS 测试真实执行)
main 分支: 如预期 FAIL —— 复现了 "Skipping skills installation" 后仍打印 "🎉 Installation complete!" 的假成功

反向验证通过,说明是真回归测试。fixture 设计到位:SHA256 校验通过后才进入内容检查(断言输出含 "SHA256 checksum verified"),排除的是"内容缺失"而非网络/校验失败;同时断言失败后不创建 ~/.agents/skills/dws。mono 用 multi-only 包、multi 用无 skills 包,两个方向都覆盖到了。

建议(非阻塞)

  1. shell 本地目录缺失分支与 ps1 不对称:ps1 的 Install-SkillsLocal 缺目录已改为带 "Skills were NOT installed." 的 throw,但 shell 的 install_skills_local(install.sh 约 959 行)仍是 say "Skipping skills installation." + return 1。set -e 下确实也会 fail-closed、不会打印成功 banner,但用户看到的最后信息是 "Skipping" 而退出码是失败,信息有误导。建议顺手对齐成 err "...Skills were NOT installed."。
  2. 小脆性提示:shell 测试 envWithSkillMode 先 append 默认值(DWS_SKILLS_ONLY=0),靠 extras 后追加覆盖,依赖 sh 后者覆盖前者的语义——现有测试已这么用且通过,仅提示。
  3. ps1 throw 会带 script position 堆栈噪声,纯美观问题。

其他

  • .changes/779-installer-skills-fail-closed.md 符合目录既有约定(category: Fixed)。
  • 覆盖缺口提醒:未测"release 包无可用 skills 但本地 source 可用"的 fallback 成功路径,但已有 source-mode 测试覆盖本地安装,可接受。
  • Windows PowerShell 5.1 原生验证依赖 CI Windows job(目前 Test (Windows) 已 SUCCESS)。

@typefield typefield left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CI 已全绿。结合上面的 CR(失败分支确实中断成功提示、throw/finally 清理正确、回归测试本地代跑通过且在 main 上反向验证可复现假成功),Approve。剩余 3 条均为非阻塞建议,可后续跟进。

@dingtalk-dws-reviewer-router
dingtalk-dws-reviewer-router Bot merged commit 52f38a4 into main Oct 22, 2026
63 of 64 checks passed
@dingtalk-dws-reviewer-router
dingtalk-dws-reviewer-router Bot deleted the codex/dwsh-49-installer-skills-fail-closed branch October 22, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] install.ps1 prints "🎉 Installation complete!" even when skills installation silently fails

2 participants