跨平台恢复 session 时 cwd 校验误拒合法绝对路径 #2405
xu-kai-quan
started this conversation in
General
Replies: 1 comment
|
Landed the same fix on zoahdev's fork so it's cherry-pick-ready too:
Your root-cause note is the key detail: it's not that the path is wrong — it's that |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
session 恢复时对
cwd的绝对路径校验按运行进程的平台判断,而不是按写入该记录时的平台判断,导致跨平台读取同一份 session 存储时,本来合法的路径被误判为"非绝对路径"而拒绝恢复。复现、预期与验收
cwd会存成形如C:\Users\bob\project的 win32 绝对路径);随后把$DSH_HOME的 session 存储目录通过同步网盘 / WSL / 挂载卷等方式,在 POSIX 主机(Linux / macOS)上打开同一个 session。session header cwd must be an absolute path, got "C:\Users\bob\project",即便该 session 的 JSONL 数据本身完好无损。packages/core/session/src/index.ts里的validateSessionHeader。根因是它用node:path的isAbsolute,该函数按校验时的process.platform解析为path.win32.isAbsolute或path.posix.isAbsolute,而不是按写入cwd时所在的平台判断。反方向(POSIX 创建 → Windows 恢复)恰好因为win32.isAbsolute('/foo')同样接受以/开头的路径而不受影响,这也是这个问题此前没被注意到的原因。validateSessionHeader对cwd的校验改为——只要path.posix.isAbsolute(cwd)或path.win32.isAbsolute(cwd)任一为真即可通过;并补充一条"恢复的 header 携带另一平台绝对路径"的用例。因为仓库当前关闭了 Pull Requests,所以按 CONTRIBUTING.md 的建议改在这里报告。修复本身很小(约 6 行改动 + 1 条测试),已经在本地完成、通过测试/typecheck/lint,并按
.agents/notes规范补了对应的双语 Agent Note,推到了 fork 分支,PR 功能开放后可以直接对比合入:https://github.com/xu-kai-quan/deepseek-harness/tree/fix/session-restore-cross-platform-cwd
All reactions