fix(interface): handle Windows drive-letter paths in --workspace-file - #1285
fix(interface): handle Windows drive-letter paths in --workspace-file#1285itzzdev09 wants to merge 2 commits into
Conversation
A Windows drive letter (`C:\path\file`) has its only colon right after the
letter. `resolve_workspace_files` and `_workspace_file_dest` each called
`spec.rpartition(":")` independently and treated any colon as the
`PATH:DEST` separator, so a bare Windows path like `C:\temp\wordlist.txt`
was split into source "C" and destination "\temp\wordlist.txt" -- argument
parsing then rejected it because no file named "C" exists.
Add a shared `_split_workspace_spec` helper used by both call sites. It
detects the drive-letter case (a single-letter `raw` immediately followed
by `\` or `/` in what would be `dest`) and treats the whole spec as the
path instead, leaving the explicit `PATH:DEST` form -- including one where
PATH itself starts with a drive letter -- unaffected, since rpartition's
rightmost split there lands on the real destination separator, not the
drive letter's colon.
Fixes usestrix#1257
The PR should not merge until the drive-letter heuristic preserves valid single-letter Findings
Prompt To Fix All With AI### Issue 1
strix/interface/utils.py:1729-1730
A valid `PATH:DEST` spec such as `a:/workspace/input.txt`, where `a` is an existing file, is now mistaken for a Windows drive path. This branch returns the entire spec as the source, so `resolve_workspace_files` looks for a file named `a:/workspace/input.txt` and rejects the argument. Absolute destinations under `/workspace/` are explicitly supported, so the drive-letter check must preserve this existing interpretation.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
|
A single-letter source declaring an absolute /workspace/... destination (a:/workspace/input.txt) has the exact same shape rpartition(:) produces for a Windows drive letter, so the drive-letter check from the previous commit wrongly claimed it too. Exclude dest values starting with /workspace/, since that explicit form's meaning is already established and must not change. Addresses review feedback from greptile-apps on usestrix#1285.
|
Good catch, thanks — this was a real regression. `a:/workspace/input.txt` (single-letter source, explicit absolute `/workspace/` destination) has the exact same shape as a Windows drive-letter path once `rpartition(":")` splits it, so the drive-letter check was firing on it too. Fixed in bdb92ad: the drive-letter case now only applies when `dest` doesn't start with `/workspace/`, since that's the one signal that reliably distinguishes "this is a real explicit destination" from "this is actually a drive letter." Both forms now work correctly — verified with two new tests, one hitting `_split_workspace_spec` directly and one going through `resolve_workspace_files` end-to-end with a real single-letter file (via `monkeypatch.chdir`, so the spec is genuinely `a:/workspace/input.txt`-shaped rather than a full path that happens to start with `a`). Both fail against the previous commit and pass now. Full suite: 56 passed (`-k workspace`), no regressions. |
Fixes #1257
Bug
--workspace-filetreats the colon in a Windows drive letter as thePATH:DESTseparator. A bare path likeC:\temp\wordlist.txtgets split into sourceCand destination\temp\wordlist.txt, so argument parsing rejects it before the scan starts (no file namedCexists).Root cause is a little wider than the single
rpartitioncall the issue points at: bothresolve_workspace_filesand_workspace_file_destindependently callspec.rpartition(":")and assume any colon found is a real separator, so fixing one without the other would have left the destination still wrong for the bare-path case.Fix
Added
_split_workspace_spec, used by both call sites, that detects the drive-letter case specifically: a single-letterrawfromrpartitionimmediately followed by\or/in what would bedest. In that case the whole spec is treated as the path with no explicit destination.The explicit
PATH:DESTform keeps working even whenPATHitself starts with a drive letter (C:\temp\wordlist.txt:dest/file), sincerpartition's rightmost split there lands on the real:dest/fileseparator, not the drive letter's colon —rawin that case is the wholeC:\temp\wordlist.txt, not a single letter, so the drive-letter check doesn't fire. Relative and POSIX paths are unaffected either way.Testing
Ran the exact repro from the issue for real (this is a Windows machine):
Before the fix: exits with the "'C' is not an existing file" argument-parsing error described in the issue.
After the fix: resolves correctly.
Added:
_split_workspace_specdirectly (bare\-path, bare/-path, and the explicitPATH:DESTform with a drive-letter source) — these fail to even collect against the old code, since the old code has no such helper to import, which is a reasonable proxy for "this is new coverage, not just documentation."resolve_workspace_filesusingtmp_pathdirectly (skipped on non-Windows, sincetmp_pathis only drive-letter-shaped here).uv run pytest tests/test_workspace_files.py— 17 passed.uv run pytest -k workspaceacross the full suite — 32 passed, no regressions.ruff check/ruff format --check/mypy/banditall clean on the two changed files (one pre-existing, unrelatedrufffinding elsewhere inutils.pyat line 877, far from this change).