[Bug] The only Windows write_file test fails, and the "system directory" check it tests can never run
Summary
write_file validator: rejects Windows system directories fails on Windows. The path-containment check rejects the path first, so the "system directory" message is unreachable. CI runs Linux only, so nobody noticed.
Steps to reproduce
- On Windows run
pnpm run test:ava source/tools/file-ops/write-file.spec.tsx. - Or call
writeFileTool.validator({path: 'C:\\Windows\\System32\\test.exe', content: 'x'}).
Expected behaviour
The test passes. The path is refused, and the test checks the message that is actually returned.
Actual behaviour
✘ [fail]: write_file validator: rejects Windows system directories
619: t.true(result.error.includes('system directory'));
Value is not `true`:
validator -> {"valid":false,"error":"Invalid file path. Path must be within the project directory."}
The write is still refused, so behaviour is safe. Only the test and the unreachable message are wrong.
Environment
Windows 11, Node v22.22.3, Nanocoder 1.31.0 (main at 948a4e74)
Suggested fix
source/tools/file-ops/write-file.spec.tsx:603-620: assert on the current message.source/tools/file-ops/write-file.tsx:463-478: remove the unreachable branch, or move it before the containment check.- Consider a Windows job in CI so tests like this do not rot.
@addyCooks
Hi! I'd like to work on this issue and contribute a fix. I'm interested in investigating the Windows-specific validation behaviour, updating the relevant test and removing or correcting the unreachable system-directory check.
Could you please assign this issue to me? I'll submit a PR with the changes.
Thanks!