Skip to content

[codex] support STAC file local paths for asset downloads#905

Open
therealclvn wants to merge 2 commits into
Open-EO:masterfrom
therealclvn:codex/asset-local-path-downloads
Open

[codex] support STAC file local paths for asset downloads#905
therealclvn wants to merge 2 commits into
Open-EO:masterfrom
therealclvn:codex/asset-local-path-downloads

Conversation

@therealclvn

Copy link
Copy Markdown

Summary

  • prefer STAC file:local_path when constructing asset download paths for directory targets
  • preserve relative subdirectories from the STAC metadata
  • reject unsafe local paths such as absolute paths, .. traversal, or Windows-style backslashes and fall back to the existing filename logic

Closes #902.

Validation

  • Red test before implementation: .venv/bin/python -m pytest tests/rest/test_job.py::TestResultAsset::test_download_uses_file_local_path -q failed because the filename fell back to asset-asset.tiff
  • .venv/bin/python -m pytest tests/rest/test_job.py::TestResultAsset::test_download_uses_file_local_path -q
  • .venv/bin/python -m pytest tests/rest/test_job.py -q
  • .venv/bin/python -m compileall openeo/rest/job.py tests/rest/test_job.py
  • git diff --check

@therealclvn therealclvn marked this pull request as ready for review July 3, 2026 14:24

@soxofaan soxofaan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some notes

(note however that this is a low-priority feature, as there are no openEO backends in the wild as far as I known that provide this metadata)

Comment thread CHANGELOG.md Outdated

### Added

- Support STAC `file:local_path` for asset download target paths. ([#902](https://github.com/Open-EO/openeo-python-client/issues/902))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

append new list items at bottom of section

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the changelog entry to the bottom of the Added section in 942b238.

Comment thread tests/rest/test_job.py
job=job,
key="asset",
href=href,
metadata={"type": "image/tiff", "file:local_path": "tiles/2026/result.tiff"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to cover all aspects of the file:local_path validation: windows separators, "..", empty dirs, non-relative paths, ....

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added invalid file:local_path cases for Windows separators, parent traversal, absolute paths, and empty paths in 942b238.

Comment thread openeo/rest/job.py Outdated
path = PurePosixPath(local_path)
if path.is_absolute() or any(p == ".." for p in path.parts):
return None
parts = [p for p in path.parts if p not in {"", "."}]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when local_path violates something (and None is returned): I would also trigger a warning to inform the user that something is wrong here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a warning when invalid file:local_path metadata is ignored in 942b238.

@therealclvn therealclvn force-pushed the codex/asset-local-path-downloads branch from 415f4af to 942b238 Compare July 3, 2026 17:35
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.

asset download: support file:local_path to determine target file name

2 participants