已关闭
bug: file-path ErrSecretDetected wrapped as misleading 'failed to read file' message #428
aflyingto创建于  7月9日关闭于  7月9日
aflyingto成员
7月9日 创建

来源

PR !368(#424)第二轮 UX 评审发现(F2)。

问题

当 --body-file/--notes-file/--description-file 指向的文件内容含当前 GC_TOKEN/GITCODE_TOKEN 值时,cmdutil.ReadTextFile 正确返回 ErrSecretDetected,但调用方将其包裹为 fmt.Errorf("failed to read file %s: %w", ...),导致错误消息类似:

Error: failed to read file body.md: content contains secret: content contains the current GC_TOKEN value

文件实际已成功读取,只是内容因安全原因被拒绝。"failed to read file" 前缀误导用户/agent 以为是 IO 错误。

影响范围

以下路径的 file 分支均有此问题:

  • 5 个本地 getBody() 的 --body-file 分支
  • pr edit --body-file(edit.go:145)
  • milestone edit --description-file(edit.go:116)
  • release create --notes-file(create.go:111)
  • release edit --notes-file(edit.go:153)

修复方向

在包裹错误前检查 errors.Is(err, cmdutil.ErrSecretDetected),若是则不添加 "failed to read file" 前缀,直接返回原始安全错误。

likedislike
Aaflyingto成员
7月9日 关联了里程碑:M2 Review Follow-ups
Aaflyingto成员
7月9日 添加了label:risk/mediumscope/security, status/triage,type/bug
Aaflyingto成员
7月9日 添加了label:status/in-progress, status/verified
Aaflyingto成员
7月9日 关联了pull request:fix: error message quality (ErrSecretDetected wrapping + 401 guidance) (#428, #432)
Aaflyingto成员
7月9日 关闭了 issue
Aaflyingto成员
7月9日 添加了label:status/merged
Aaflyingto成员
8月4日 添加了label:status/self-checked