Skip to content

feat(snapshots): Add endpoint for downloading images zip#115337

Merged
NicoHinderling merged 1 commit into
masterfrom
05-11-feat_snapshots_add_endpoint_for_downloading_images_zip
May 12, 2026
Merged

feat(snapshots): Add endpoint for downloading images zip#115337
NicoHinderling merged 1 commit into
masterfrom
05-11-feat_snapshots_add_endpoint_for_downloading_images_zip

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

@NicoHinderling NicoHinderling commented May 11, 2026

Summary

  • Adds a new streaming download endpoint (/preprodartifacts/snapshots/<id>/download/) that bundles all snapshot images into a zip file. Images are fetched concurrently in batches (32 workers, 200 per batch) and deduplicated by content hash before zipping. The response is streamed as a StreamingHttpResponse — chunks are yielded as each batch is zipped, so the client starts receiving data immediately without buffering the entire archive in memory.
  • This follows the same streaming download pattern already used by the existing size build artifact download endpoint (project_preprod_artifact_download.py), which also uses StreamingHttpResponse for large file downloads.
  • Uses a non-seekable _DrainableBuffer so zipfile writes data descriptors (no seeking back to update headers), enabling true streaming output.
  • Replaces the fragile **dict() spread pattern in SnapshotImageResponse construction with explicit field assignments (description, tags). The old approach silently forwarded unknown fields via **kwargs filtering, which was brittle and hard to follow.

Test plan

  • Hit the download endpoint for an existing snapshot and verify the returned zip contains the expected image files
  • Verify 404 is returned for non-existent snapshot IDs
  • Verify 403 is returned when the feature flag is disabled
  • Confirm that description and tags fields are still returned correctly in the snapshot detail response

Copy link
Copy Markdown
Contributor Author

NicoHinderling commented May 11, 2026

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 11, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review May 11, 2026 22:00
@NicoHinderling NicoHinderling requested a review from a team as a code owner May 11, 2026 22:00
@getsantry getsantry Bot requested a review from a team as a code owner May 11, 2026 22:01
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 11, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.47%

@NicoHinderling NicoHinderling force-pushed the 05-11-feat_snapshots_add_endpoint_for_downloading_images_zip branch from 367ae5e to 1ebb99a Compare May 11, 2026 22:08
Comment thread src/sentry/preprod/api/endpoints/preprod_artifact_snapshot_download.py Outdated
Comment thread src/sentry/preprod/api/endpoints/preprod_artifact_snapshot_download.py Outdated
@NicoHinderling NicoHinderling force-pushed the 05-11-feat_snapshots_add_endpoint_for_downloading_images_zip branch from 1ebb99a to 677bcff Compare May 11, 2026 22:36
Comment thread src/sentry/preprod/api/endpoints/preprod_artifact_snapshot_download.py Outdated
Comment thread src/sentry/preprod/api/endpoints/preprod_artifact_snapshot_download.py Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e990e2b. Configure here.

@NicoHinderling NicoHinderling force-pushed the 05-11-feat_snapshots_add_endpoint_for_downloading_images_zip branch from 5db78fd to 1c91f37 Compare May 11, 2026 23:36
@NicoHinderling NicoHinderling force-pushed the 05-11-feat_snapshots_add_endpoint_for_downloading_images_zip branch from 1c91f37 to f9b8a7e Compare May 11, 2026 23:47
@NicoHinderling NicoHinderling requested a review from a team as a code owner May 11, 2026 23:47
@NicoHinderling NicoHinderling force-pushed the 05-11-feat_snapshots_add_endpoint_for_downloading_images_zip branch from f9b8a7e to 80054f9 Compare May 11, 2026 23:50
@NicoHinderling NicoHinderling merged commit 512682b into master May 12, 2026
64 of 65 checks passed
@NicoHinderling NicoHinderling deleted the 05-11-feat_snapshots_add_endpoint_for_downloading_images_zip branch May 12, 2026 02:29
NicoHinderling added a commit that referenced this pull request May 12, 2026
Screenshots:
<img width="688" height="800" alt="image"
src="https://github.com/user-attachments/assets/9a234440-405a-428f-b5fe-a8969e94e359"
/>

<img width="1274" height="1842" alt="image"
src="https://github.com/user-attachments/assets/60e7b20d-45a9-465c-81fd-504ca8f4b931"
/>

## Summary

Frontend companion to #115337. Adds a "Download Images" action to the
snapshot header dropdown menu that fetches the zip from the new download
endpoint and triggers a browser download.

Also cleans up the `SnapshotImage` type and test fixtures:
- Removes `content_hash` from the frontend `SnapshotImage` interface —
it's an internal storage detail not needed by the UI
- Stops filtering `content_hash` from the metadata copy-to-clipboard
JSON (since the field is gone)
- Filters out `null` values from the metadata JSON to reduce noise
- Reorders dropdown menu items: Build Metadata → View Base Build →
Download Images → Rerun Status Checks → Delete

## Test plan
- [ ] Open a snapshot detail page and verify the dropdown menu shows the
new "Download Images" option
- [ ] Click "Download Images" and confirm the zip downloads with the
correct filename
- [ ] Verify the metadata copy button no longer includes `content_hash`
or null fields
- [ ] Confirm existing snapshot stories still render correctly without
`content_hash`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants