Repository navigation
fix: resolve document paths against option "documents" directories - #899
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📊 Benchmark Results
vs main branch (2026-04-23)
What do these numbers mean?
|
There was a problem hiding this comment.
Pull request overview
Fixes #889 by improving how document directive file paths are resolved, preferring option "documents" directories before falling back to the current working directory.
Changes:
- Add
document_dirstoValidationOptionsand plumb it from loader/LSP into validation. - Update document validator to search
document_dirswhen resolving relative document paths. - Add validation tests for relative/absolute document path behaviors; add
tempfiledev-dependency.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rustledger-validate/src/validators/document.rs | Resolve relative document paths by searching configured document directories and improve error context |
| crates/rustledger-validate/src/lib.rs | Introduce document_dirs on ValidationOptions and add tests covering the new behavior |
| crates/rustledger-validate/Cargo.toml | Add tempfile dev dependency for filesystem-based tests |
| crates/rustledger-loader/src/process.rs | Pass documents option into validator options |
| crates/rustledger-lsp/src/handlers/diagnostics.rs | Forward documents option into validation options for both loader-based and file-based validation |
| README.md | Adds/updates “bank import” documentation and links |
| Cargo.lock | Lockfile update for tempfile |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
d410d31 to
30d5c3d
Compare
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
30d5c3d to
7370ffe
Compare
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
7370ffe to
cf3c41a
Compare
…tability - Change ValidationOptions.document_dirs from Vec<String> to Vec<PathBuf> to store resolved paths instead of raw values - Add #[non_exhaustive] to ValidationOptions to prevent breaking changes when new fields are added - Resolve document paths against source_map base_dir in run_validation() and build_validation_options_from_loader() to match run_plugins() behavior - Use Path::join() instead of string concatenation for portable paths - Fix test to use doc_subdir.join() instead of format! for path construction Addresses Copilot review comments #1, #2, #3, #4, #5, #7 on PR #899
cf3c41a to
ae5e560
Compare
Summary
Fix #889:
documentdirectives with relative paths (e.g."./credit-card-statement.pdf") now resolve againstoption "documents"directories before falling back to CWD.This PR builds on main (which already has the basic
document_dirssearch) to:PathBufinstead of rawStringso resolution is stable regardless of the process CWDValidationOptions#[non_exhaustive]+ add builder methods so downstream crates don't break when new fields are addedPath::joineverywhere (no more OS-specific"{}/{}"concat)Changes
rustledger-validate:ValidationOptions.document_dirs: Vec<PathBuf>(wasVec<String>)#[non_exhaustive]onValidationOptionswith_account_types,with_require_commodities,with_check_documents,with_warn_future_dates,with_document_dirs,with_infer_tolerance_from_cost,with_tolerance_multiplier,with_inferred_tolerance_defaultvalidate_documentdoc comment describes resolution precedence (absolute →document_base→document_dirs→ CWD fallback)rustledger_test_889_*.pdf) to avoid CWD collisionstempfilenow usestempfile.workspace = truefor consistency with the rest of the workspacerustledger-loader:run_validationbuildsValidationOptionsvia builder chain, passes resolvedVec<PathBuf>document dirsrustledger-lsp:build_validation_options_from_loaderandbuild_validation_options_from_filereturnVec<PathBuf>and use builder methods; signatures preserve thebase_dir: Option<&Path>threading added by fix: add STRICT_WITH_SIZE to parser valid booking methods #900Known CI failures
ValidationOptions.document_dirstype change (Vec<String>→Vec<PathBuf>) is a breaking change requiring a major version bump. Addressed separately at release time.Copilot review comments addressed
All 7 original + 4 re-review comments addressed:
#[non_exhaustive]+ builder methods eliminate struct-literal breakagePathBuf::joininstead offormat!with path separatorsPath::joinfor portable pathstempfilenow uses workspace dependencybuild_validation_options_from_filereplaced