fix(paths): structurally resolve home dir to prevent Windows path bugs#12125
fix(paths): structurally resolve home dir to prevent Windows path bugs#12125sebslight merged 2 commits intoopenclaw:mainfrom
Conversation
|
Hey @sebslight, this is a follow-up to your #12091 work. On Windows, The fix has two parts:
Would love your thoughts when you have a moment! |
4ab6cd8 to
4be3c50
Compare
4be3c50 to
d586252
Compare
Extract resolveRawHomeDir as a private function and gate the public
resolveEffectiveHomeDir through a single path.resolve() exit point.
This makes it structurally impossible for unresolved paths (missing
drive letter on Windows) to escape the function, regardless of how
many return paths exist in the raw lookup logic.
Simplify resolveRequiredHomeDir to only resolve the process.cwd()
fallback, since resolveEffectiveHomeDir now returns resolved values.
Fix shortenMeta in tool-meta.ts: the colon-based split for file:line
patterns (e.g. file.txt:12) conflicts with Windows drive letters
(C:\...) because indexOf(":") matches the drive colon first.
shortenHomeInString already handles file:line patterns correctly via
split/join, so the colon split was both unnecessary and harmful.
Update test assertions across all affected files to use path.resolve()
in expected values and input strings so they match the now-correct
resolved output on both Unix and Windows.
Fixes openclaw#12119
d586252 to
b04330e
Compare
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
openclaw#12125) * fix(paths): structurally resolve home dir to prevent Windows path bugs Extract resolveRawHomeDir as a private function and gate the public resolveEffectiveHomeDir through a single path.resolve() exit point. This makes it structurally impossible for unresolved paths (missing drive letter on Windows) to escape the function, regardless of how many return paths exist in the raw lookup logic. Simplify resolveRequiredHomeDir to only resolve the process.cwd() fallback, since resolveEffectiveHomeDir now returns resolved values. Fix shortenMeta in tool-meta.ts: the colon-based split for file:line patterns (e.g. file.txt:12) conflicts with Windows drive letters (C:\...) because indexOf(":") matches the drive colon first. shortenHomeInString already handles file:line patterns correctly via split/join, so the colon split was both unnecessary and harmful. Update test assertions across all affected files to use path.resolve() in expected values and input strings so they match the now-correct resolved output on both Unix and Windows. Fixes openclaw#12119 * fix(changelog): add paths Windows fix entry (openclaw#12125) --------- Co-authored-by: Sebastian <[email protected]>
openclaw#12125) * fix(paths): structurally resolve home dir to prevent Windows path bugs Extract resolveRawHomeDir as a private function and gate the public resolveEffectiveHomeDir through a single path.resolve() exit point. This makes it structurally impossible for unresolved paths (missing drive letter on Windows) to escape the function, regardless of how many return paths exist in the raw lookup logic. Simplify resolveRequiredHomeDir to only resolve the process.cwd() fallback, since resolveEffectiveHomeDir now returns resolved values. Fix shortenMeta in tool-meta.ts: the colon-based split for file:line patterns (e.g. file.txt:12) conflicts with Windows drive letters (C:\...) because indexOf(":") matches the drive colon first. shortenHomeInString already handles file:line patterns correctly via split/join, so the colon split was both unnecessary and harmful. Update test assertions across all affected files to use path.resolve() in expected values and input strings so they match the now-correct resolved output on both Unix and Windows. Fixes openclaw#12119 * fix(changelog): add paths Windows fix entry (openclaw#12125) --------- Co-authored-by: Sebastian <[email protected]>
openclaw#12125) * fix(paths): structurally resolve home dir to prevent Windows path bugs Extract resolveRawHomeDir as a private function and gate the public resolveEffectiveHomeDir through a single path.resolve() exit point. This makes it structurally impossible for unresolved paths (missing drive letter on Windows) to escape the function, regardless of how many return paths exist in the raw lookup logic. Simplify resolveRequiredHomeDir to only resolve the process.cwd() fallback, since resolveEffectiveHomeDir now returns resolved values. Fix shortenMeta in tool-meta.ts: the colon-based split for file:line patterns (e.g. file.txt:12) conflicts with Windows drive letters (C:\...) because indexOf(":") matches the drive colon first. shortenHomeInString already handles file:line patterns correctly via split/join, so the colon split was both unnecessary and harmful. Update test assertions across all affected files to use path.resolve() in expected values and input strings so they match the now-correct resolved output on both Unix and Windows. Fixes openclaw#12119 * fix(changelog): add paths Windows fix entry (openclaw#12125) --------- Co-authored-by: Sebastian <[email protected]>
openclaw#12125) * fix(paths): structurally resolve home dir to prevent Windows path bugs Extract resolveRawHomeDir as a private function and gate the public resolveEffectiveHomeDir through a single path.resolve() exit point. This makes it structurally impossible for unresolved paths (missing drive letter on Windows) to escape the function, regardless of how many return paths exist in the raw lookup logic. Simplify resolveRequiredHomeDir to only resolve the process.cwd() fallback, since resolveEffectiveHomeDir now returns resolved values. Fix shortenMeta in tool-meta.ts: the colon-based split for file:line patterns (e.g. file.txt:12) conflicts with Windows drive letters (C:\...) because indexOf(":") matches the drive colon first. shortenHomeInString already handles file:line patterns correctly via split/join, so the colon split was both unnecessary and harmful. Update test assertions across all affected files to use path.resolve() in expected values and input strings so they match the now-correct resolved output on both Unix and Windows. Fixes openclaw#12119 * fix(changelog): add paths Windows fix entry (openclaw#12125) --------- Co-authored-by: Sebastian <[email protected]>
openclaw#12125) * fix(paths): structurally resolve home dir to prevent Windows path bugs Extract resolveRawHomeDir as a private function and gate the public resolveEffectiveHomeDir through a single path.resolve() exit point. This makes it structurally impossible for unresolved paths (missing drive letter on Windows) to escape the function, regardless of how many return paths exist in the raw lookup logic. Simplify resolveRequiredHomeDir to only resolve the process.cwd() fallback, since resolveEffectiveHomeDir now returns resolved values. Fix shortenMeta in tool-meta.ts: the colon-based split for file:line patterns (e.g. file.txt:12) conflicts with Windows drive letters (C:\...) because indexOf(":") matches the drive colon first. shortenHomeInString already handles file:line patterns correctly via split/join, so the colon split was both unnecessary and harmful. Update test assertions across all affected files to use path.resolve() in expected values and input strings so they match the now-correct resolved output on both Unix and Windows. Fixes openclaw#12119 * fix(changelog): add paths Windows fix entry (openclaw#12125) --------- Co-authored-by: Sebastian <[email protected]>
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
openclaw#12125) * fix(paths): structurally resolve home dir to prevent Windows path bugs Extract resolveRawHomeDir as a private function and gate the public resolveEffectiveHomeDir through a single path.resolve() exit point. This makes it structurally impossible for unresolved paths (missing drive letter on Windows) to escape the function, regardless of how many return paths exist in the raw lookup logic. Simplify resolveRequiredHomeDir to only resolve the process.cwd() fallback, since resolveEffectiveHomeDir now returns resolved values. Fix shortenMeta in tool-meta.ts: the colon-based split for file:line patterns (e.g. file.txt:12) conflicts with Windows drive letters (C:\...) because indexOf(":") matches the drive colon first. shortenHomeInString already handles file:line patterns correctly via split/join, so the colon split was both unnecessary and harmful. Update test assertions across all affected files to use path.resolve() in expected values and input strings so they match the now-correct resolved output on both Unix and Windows. Fixes openclaw#12119 * fix(changelog): add paths Windows fix entry (openclaw#12125) --------- Co-authored-by: Sebastian <[email protected]>
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
#12125) * fix(paths): structurally resolve home dir to prevent Windows path bugs Extract resolveRawHomeDir as a private function and gate the public resolveEffectiveHomeDir through a single path.resolve() exit point. This makes it structurally impossible for unresolved paths (missing drive letter on Windows) to escape the function, regardless of how many return paths exist in the raw lookup logic. Simplify resolveRequiredHomeDir to only resolve the process.cwd() fallback, since resolveEffectiveHomeDir now returns resolved values. Fix shortenMeta in tool-meta.ts: the colon-based split for file:line patterns (e.g. file.txt:12) conflicts with Windows drive letters (C:\...) because indexOf(":") matches the drive colon first. shortenHomeInString already handles file:line patterns correctly via split/join, so the colon split was both unnecessary and harmful. Update test assertions across all affected files to use path.resolve() in expected values and input strings so they match the now-correct resolved output on both Unix and Windows. Fixes #12119 * fix(changelog): add paths Windows fix entry (#12125) --------- Co-authored-by: Sebastian <[email protected]>
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
resolveDefaultConfigCandidates returns resolved paths (with drive letter on Windows) after upstream openclaw#12125. The test used raw path.join with a Unix-style home, missing the drive prefix.
Fixes #12119
Problem
resolveEffectiveHomeDir()returned raw env-var values (e.g.OPENCLAW_HOME="/custom/home") without callingpath.resolve(). On POSIX this is harmless, but on Windowspath.join("/custom/home", ".openclaw")produces\custom\home\.openclaw(missing the drive letter), breakingSTATE_DIRandCONFIG_PATHderivation.Additionally,
shortenMeta()intool-meta.tsusedindexOf(":")to split file:line patterns (e.g.file.txt:12), but this conflicts with Windows drive letters (C:\...) where the colon appears at index 1.Both issues were introduced/exposed by #12091 which added
OPENCLAW_HOMEsupport.Fix
Structural gate (
home-dir.ts): Extract the raw lookup logic into a privateresolveRawHomeDir()and gate the publicresolveEffectiveHomeDir()through a singlepath.resolve()exit point. This makes it structurally impossible for unresolved paths to escape, regardless of how many return paths exist. Future developers can add new env-var sources without rememberingpath.resolve().Simplify
resolveRequiredHomeDir: Remove the now-redundantpath.resolve()wrapper — only theprocess.cwd()fallback needs it.Fix
shortenMeta(tool-meta.ts): Remove the colon-based split that conflicts with Windows drive letters.shortenHomeInString()already handles file:line patterns correctly viasplit(home).join(prefix), so the colon split was both unnecessary and harmful.Tests: Update assertions across all affected files to use
path.resolve()in expected values and input strings so they match the now-correct resolved output on both Unix and Windows.Test plan
home-dir.test.tstests passtool-meta.test.tstests passutils.test.tstests passagent-scope.test.tstests passpaths.test.tstests passconfig.nix-integration-u3-u5-u9.test.tstests passworkspace.test.tstests passprofile.test.tstests passsession-utils.fs.test.tstests passpnpm build && pnpm checkcleanchecks-windows) passes