Skip to content

test: confine snapshot copy mode to the workspace - #804

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/snapshot-artifact-uri-tests-83cf
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/snapshot-artifact-uri-tests-83cf

Conversation

@cursor

@cursor cursor Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

Adds tests that snapshot export in copy mode must not read artifact URIs outside the workspace that owns the catalog. The workspace root is the parent of the catalog directory. Files inside that root are still copied. Paths that resolve outside it, including symlinks, .. segments, relative paths, and a path swapped for another file between lookup and read, are refused before their bytes are written. An object-store URL in a local catalog is refused the same way.

These tests fail on purpose until that containment exists. No production code is changed here.

Why

export_dataset_snapshot(..., media_mode=copy) and hflow export snapshot --media copy take each artifact/ measurement value_text and pass it to fetch_uri, then copy the bytes into assets/. The catalog row is data, not a path the operator typed. A local path outside the data root and an s3:// URL are both copied with the exporting process's filesystem rights and ambient object-store configuration.

References mode is unchanged: it keeps the URI as a pointer and does not read it.

Validation

uv run ruff check tests/test_snapshot_artifact_uri_containment.py — passed.

uv run ty check tests/test_snapshot_artifact_uri_containment.py — passed.

uv run pytest -q tests/test_snapshot_artifact_uri_containment.py — 7 failed, 2 passed. The failures are the containment cases and are expected until copy mode refuses outside URIs. The two passes are in-workspace copy and references mode.

Checklist

  • I added or updated outcome-focused tests for changed business logic.
  • I updated documentation for changed behavior, flags, formats, or requirements.
  • I ran uv run ruff check --fix, uv run ruff format, and uv run ty check.
  • I ran the relevant pytest suite.
  • I did not add recordings, generated media, credentials, private URLs, or runtime artifacts.
  • I preserved stored-data compatibility or documented an explicit version change.
Open in Web Open in Cursor 

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Copy mode currently materializes any artifact URI stored in the catalog.
These tests refuse local paths and object-store URLs that resolve outside
the catalog's parent workspace, including symlink and lookup swaps, and
they fail until that containment exists.
cursor Bot pushed a commit that referenced this pull request Nov 20, 2026
Bring the copy-mode containment regressions from #804 into this change:
absolute paths, the CLI, symlinks, parent segments, relative escapes, a
file swapped for a symlink after its status lookup, and an object-store
URL in a local catalog are refused without writing their bytes, while
in-workspace artifacts still copy and references mode never reads URIs.
The swapped-file case now requires refusal outright.
@kstonekuan

Copy link
Copy Markdown
Contributor

Tracking the fix and regression coverage in #808.

@kstonekuan kstonekuan closed this Nov 20, 2026
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.

2 participants