Skip to content

fix(images): resolve relative images when base path is a file URI - #4921

Closed
taran-dev4u wants to merge 1 commit into
docling-project:mainfrom
taran-dev4u:fix/file-uri-image-base-path
Closed

taran-dev4u wants to merge 1 commit into
docling-project:mainfrom
taran-dev4u:fix/file-uri-image-base-path

Conversation

@taran-dev4u

Copy link
Copy Markdown
Contributor

Issue resolved by this Pull Request:
Resolves #4911

When source_uri is supplied as a file:// URI, ImageResourceLoader.resolve_relative_path previously rejected it with ValueError: Invalid base_path format because is_local_path only recognized raw filesystem paths. This adds is_file_uri and file_uri_to_path helpers to normalize file URIs to local paths for directory confinement and relative image resolution, and allows file URI base paths in HTML and JATS figure loading.

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:
Before this change, passing a file:// URI as source_uri with fetch_images=True raised ValueError: Invalid base_path format: 'file:///...' during image resolution. After this change, relative images resolve against the local file URI directory while preserving path traversal and absolute path guards. Added unit tests in tests/test_backend_html.py (test_resolve_relative_path_file_uri) and tests/test_backend_markdown.py (test_local_relative_image_resolved_with_file_uri_source).

Allow file:// URIs as base_path in ImageResourceLoader.resolve_relative_path and normalize them to filesystem paths for directory confinement and local resolution. Support file URI base paths in HTML and JATS figure loading, and add unit tests.

Fixes docling-project#4911.

Signed-off-by: Taran Mamidala <mamidalataran6333@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @taran-dev4u, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@taran-dev4u
taran-dev4u marked this pull request as ready for review October 20, 2026 17:59
@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working html issue related to html backend xml issue related to supported schema-specific XML formats labels Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 55c1b3ea50. The analysis read the diff only. It did not run code from this pull request.

The PR makes ImageResourceLoader.resolve_relative_path accept a file:// URI as the base path. It adds is_file_uri and file_uri_to_path helpers, and it uses them in the HTML and JATS backends.

Topic labels added: bug, html, xml.

CI safety: no concern found. A maintainer must still approve CI.

Possible duplicates

PR State Signal Assessment
#4912 open also references issue #4911; changes the same code duplicate: Both PRs fix the same ValueError for a file:// base path in ImageResourceLoader.resolve_relative_path. They edit the same function and add similar tests in the same two test files, so only one can be merged.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@taran-dev4u

Copy link
Copy Markdown
Contributor Author

Closing in favor of #4912, which was opened earlier.

@taran-dev4u
taran-dev4u deleted the fix/file-uri-image-base-path branch October 20, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working html issue related to html backend xml issue related to supported schema-specific XML formats

Projects

None yet

Development

Successfully merging this pull request may close these issues.

file:// source_uri is rejected as an image base path

1 participant