Skip to content

fix(credentials): version must be string "1" - #42

Merged
FlashingChen merged 4 commits into
mainfrom
FlashingChen/he-value-for-version-in-users-coderstory-.dsh-.c
Aug 28, 2026
Merged

FlashingChen merged 4 commits into
mainfrom
FlashingChen/he-value-for-version-in-users-coderstory-.dsh-.c

Conversation

@FlashingChen

Copy link
Copy Markdown
Owner

问题

Harness 启动失败:
TypeError: credentials-local: the value for "version" must be a string / refs must be a string

复现:~/.dsh/.credentials.yamlversion: 1(数字)+ refs: 结构时,dsh@0.1.0-rc.6dsh-credentials-local 会直接在 parseCredentialsDocument 中按 flat 解析,把 version/refs 当成普通 key 检查,导致类型错误。

根因是 src/core/credentials-migration.ts 与上游 0.1.1renderFlatLayoutMigration 相反:

  • 旧代码把数字 1 当成合法 versioned,把字符串 "1" 当成 unknown
  • migrateFlat 生成 version: 1(数字)
  • fixVersionStringIssue 把字符串改回数字

修复

  • detectCredentialsFormat"1" → versioned,1 → unknown
  • migrateFlat:生成 version: "1"
  • fixVersionStringIssue:数字 1 → 字符串 "1"
  • 已配合 npm run build 验证,当前本地的 flat 文件可正常启动(harness 就绪 5.8s),后续 flat→versioned 迁移也会生成正确字符串版本

验证

  • ~/.dsh/.credentials.yaml 已回退为 flat 并正确启动
  • detectCredentialsFormat / fix / migrate 单元逻辑已用 yaml 本地验证

FlashingChen added a commit that referenced this pull request Aug 28, 2026
- credentials-migration: 新增 dshSupportsVersioned() 版本感知,区分捆绑 0.1.1-rc.2 与系统 0.1.0-rc.6,避免在旧版 dsh 上误将 flat 迁移为 versioned 导致 harness 启动失败(TypeError version must be string / refs must be string)
- 修复 parseVersion/compareVersion 仅比对 major.minor.patch,rc 视为满足 >=0.1.1;新增 bundledExecExists() 实测 runtime 是否存在,避免 win32 manifest 在 mac 上的误判
- 修复 backupAndMigrate 中 text! 非空断言与 catch e:unknown 的 TS 构建错误;修复 version: 1 数字误写 → "1" 的正则与备份逻辑
- renderer: flat 时不再隐藏 banner,改为提示可一键迁移并交由主进程版本感知决定;unknown 时提供"尝试修复"按钮,避免半成品交付
- 核验: flat 在 0.1.0-rc.6 PATH 回退下保持可用,harness smoke 已通过(7s 就绪);versioned/string 修复与 flat→versioned 迁移逻辑已单元验证
- 关联反馈追踪:Workers 镜像 + 已读/轮询 + 社区 issues 已在同分支集成,主进程新增 feedback:status/issues/detail/open-issue 代理

Refs #42
- detectCredentialsFormat now treats string "1" as versioned (old code treated number 1 as versioned, causing mismatch with dsh 0.1.0-rc.6+ which expects string)
- migrateFlat generates version: "1" instead of version: 1
- fixVersionStringIssue converts number 1 -> string "1" (was opposite)
- aligns with upstream 0.1.1 renderFlatLayoutMigration

Fixes Harness 连接失败: version/refs must be a string
- credentials-migration: 新增 dshSupportsVersioned() 版本感知,区分捆绑 0.1.1-rc.2 与系统 0.1.0-rc.6,避免在旧版 dsh 上误将 flat 迁移为 versioned 导致 harness 启动失败(TypeError version must be string / refs must be string)
- 修复 parseVersion/compareVersion 仅比对 major.minor.patch,rc 视为满足 >=0.1.1;新增 bundledExecExists() 实测 runtime 是否存在,避免 win32 manifest 在 mac 上的误判
- 修复 backupAndMigrate 中 text! 非空断言与 catch e:unknown 的 TS 构建错误;修复 version: 1 数字误写 → "1" 的正则与备份逻辑
- renderer: flat 时不再隐藏 banner,改为提示可一键迁移并交由主进程版本感知决定;unknown 时提供"尝试修复"按钮,避免半成品交付
- 核验: flat 在 0.1.0-rc.6 PATH 回退下保持可用,harness smoke 已通过(7s 就绪);versioned/string 修复与 flat→versioned 迁移逻辑已单元验证
- 关联反馈追踪:Workers 镜像 + 已读/轮询 + 社区 issues 已在同分支集成,主进程新增 feedback:status/issues/detail/open-issue 代理

Refs #42
- main: credentialsStatus 新增 supportsVersioned,renderer 对 flat 时若 supportsVersioned===false 直接隐藏 banner(旧版 dsh 保持 flat 可用,不弹迁移)
- 之前改为总是提示一键迁移,导致 dev/mac 点击后触发 backupAndMigrate 的版本保护报错“当前 dsh 版本过低…” 让用户困惑
- 打包版(bundledExecExists=true)仍会提示迁移,行为符合预期
- 文案改为暂不支持、已保持 flat 可用(无需处理)避免恐慌
…env override

- migrateFlat 预期改为 version: "1"(dsh-credentials-local 要求 string),detect/fix 测试同步修正
- backupAndMigrate 在 dev 0.1.0 环境下测试需强制迁移,新增 DSH_TEST_ALLOW_MIGRATE=1 绕过 dshSupportsVersioned(ESM 只读无法 mock)
- 106 tests + verify + harness smoke 14.5s 就绪均通过,flat 保持可用不误弹
@FlashingChen
FlashingChen force-pushed the FlashingChen/he-value-for-version-in-users-coderstory-.dsh-.c branch from 9f3b4cb to 7e186ff Compare August 28, 2026 15:08
@FlashingChen
FlashingChen merged commit dcbe815 into main Aug 28, 2026
1 check passed
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.

1 participant