fix(cli): resolve relative paths before computing file URI - #3
Merged
Conversation
bigos parse <relative.pdf> raised ValueError: 'relative path can't be expressed as a file URI' because Path.as_uri() refuses any non-absolute path. The README's quickstart example (bigos parse contract.pdf) hit this on every invocation from a normal cwd. Resolve the user-supplied path to absolute before calling as_uri() and use the resolved path for hashing too (so symlinks/canonical paths flow into the cache key consistently). Add a regression test that runs the parse command with a relative path through Typer's CliRunner and asserts the resulting Source.uri is an absolute file:// URI. Co-authored-by: Bartłomiej Rosa <bartrosa@users.noreply.github.com>
bartrosa
marked this pull request as ready for review
May 23, 2026 12:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug & impact
The
bigos parseCLI crashed withValueError: relative path can't be expressed as a file URIwhenever the user passed a relative path — e.g. the exact invocation shown in the README quickstart:Reproduction (slightly trimmed):
Impact: every documented quickstart invocation from a normal working directory aborts before any parsing happens. The CLI is the primary entry point of the package, so this is high blast-radius user-facing breakage.
Root cause
Path.as_uri()is only defined for absolute paths. Typer/Click's defaultPathparameter (resolve_path=False) hands the user-supplied string through verbatim, sopathin theparsecommand stayed relative. Theas_uri()call therefore raised on any relative input.Fix
src/bigos/cli.py: resolve the input path to absolute (path.resolve()) before callingas_uri(), and reuse the resolved path forsha256_file()so the URI and the hashed bytes always refer to the same canonical location.Validation
test_cli_relative_path_does_not_crash_with_value_errorintests/test_cli.pyinvokes the CLI through Typer'sCliRunnerwith a relative path (using a stub backend) and asserts the resultingSource.uriis a valid absolutefile://URI.pytest -m "not slow"→ 54 passed;pytest tests/test_cli.py(incl. slow Docling parse tests) → 6 passed..resolve()plus a passthrough.