Skip to content

fix(paths): handle cwd-relative input in validate_for_add / validate_for_get#192

Draft
CGMossa wants to merge 1 commit into
mainfrom
fix/resolve-paths-pass-through
Draft

fix(paths): handle cwd-relative input in validate_for_add / validate_for_get#192
CGMossa wants to merge 1 commit into
mainfrom
fix/resolve-paths-pass-through

Conversation

@CGMossa
Copy link
Copy Markdown
Contributor

@CGMossa CGMossa commented May 11, 2026

The validate_for_add / validate_for_get path checks expect repo-relative paths, but callers running from a subdir hand them cwd-relative input. Today the cwd→repo-relative conversion lives inside resolve_paths_for_*, so any caller that wants per-row Error rows (instead of the bail-on-canonicalize-failure behavior) has no way to skip the resolver without losing the conversion. This moves the conversion into the validators themselves so per-row classification works against raw user input. CLI behavior unchanged — it still calls resolve_paths_for_*. Required by #193, which uses the per-row form from the R binding.

AI-written details

Summary

  • validate_for_* previously did self.repo_root.join(path), which only matched when the caller had already converted to repo-relative form (the side-effect of going through resolve_paths_for_*).
  • This makes the validators self-sufficient: a new private DvsPaths::user_path_to_repo_relative handles the cwd→repo-relative conversion, and the returned tuple carries the repo-relative form so downstream file_path / metadata_path calls keep working.
  • Callers can now hand user input straight to add_files / get_files and the per-row AddDetail::Error / GetDetail::Error machinery in validate_for_* does the right thing.

Test plan

  • cargo test -p dvs --lib passes (existing validate_for_add test covers Valid / NotFound / OutsideProject / IsDirectory)
  • dvs add missing.bin from a subdir unchanged (CLI still routes through resolve_paths_for_add which still bails on canonicalize failure)
  • Companion feat(rpkg): return event state as data.frame or list-of-data.frames #193 exercises the new behavior via 12 R-side scenarios in ui/main_events.sh

Notes

  • CLI impact: none. The CLI keeps calling resolve_paths_for_* which keeps its bail-on-missing behavior. This PR only makes the per-row path usable for callers that want to skip the resolver.
  • Required by feat(rpkg): return event state as data.frame or list-of-data.frames #193: that PR's rpkg bypasses resolve_paths_for_* when no glob is supplied and relies on the per-row classification this PR makes accessible.

Drafted by Claude (claude-opus-4-7). Reviewed by the author.

@CGMossa
Copy link
Copy Markdown
Contributor Author

CGMossa commented May 11, 2026

from vincent

so if canonicalize fails that means the file doesn't exist and in that case the user explicitly passed that path since globbing would not have resolved to an inexistent path
git errors in that case for the whole thing, i did the same behaviour (edited)

I believe this means that this PR adds an unnecessary mechanism. I need to read the code and understand this bit. While dvs-lib is very excellently written, it is hard both for me and AI to follow what happens.

@CGMossa CGMossa marked this pull request as draft May 11, 2026 18:54
@CGMossa CGMossa marked this pull request as draft May 11, 2026 18:54
@CGMossa CGMossa force-pushed the fix/resolve-paths-pass-through branch from 3579d3e to 443abcb Compare May 14, 2026 07:23
@CGMossa CGMossa changed the title fix(globbing): surface per-path failures instead of bailing fix(paths): handle cwd-relative input in validate_for_add / validate_for_get May 14, 2026
@CGMossa CGMossa force-pushed the fix/resolve-paths-pass-through branch from 443abcb to 79e65df Compare May 16, 2026 09:27
…ive input

When the user is in a subdirectory of the repo, they type paths
relative to their cwd (e.g. \`file.bin\` from \`/repo/sub/\`). The
\`validate_for_*\` checks today do \`self.repo_root.join(path)\`, which
anchors at the wrong directory and only works correctly when the
caller has already converted to a repo-relative form.

That conversion currently lives inside \`resolve_paths_for_add\` /
\`resolve_paths_for_get\`, which means callers that want per-row
\`AddDetail::Error\` / \`GetDetail::Error\` rows (rather than the bail
on canonicalize failure that \`resolve_paths_*\` does) can't bypass
those helpers — they need the conversion side-effect.

Move the cwd→repo-relative conversion into the validators (private
\`DvsPaths::user_path_to_repo_relative\`). Now callers can hand
user input straight to \`add_files\` / \`get_files\` and the
per-row error machinery in \`validate_for_*\` does the right thing.
The returned tuple carries the repo-relative form so downstream
\`file_path\` / \`metadata_path\` calls remain correct.

CLI behavior unchanged: it still calls \`resolve_paths_for_*\` which
still bails on missing paths.
@CGMossa CGMossa force-pushed the fix/resolve-paths-pass-through branch from 79e65df to 2270fcf Compare May 17, 2026 09:17
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