Skip to content

ref(preprod): Download snapshot images via direct browser request#116795

Merged
NicoHinderling merged 2 commits into
masterfrom
ref/snapshot-images-direct-download
Jun 3, 2026
Merged

ref(preprod): Download snapshot images via direct browser request#116795
NicoHinderling merged 2 commits into
masterfrom
ref/snapshot-images-direct-download

Conversation

@NicoHinderling

Copy link
Copy Markdown
Contributor

Simplify the snapshot image download to use a direct browser navigation to the download endpoint rather than fetching the zip blob in JavaScript first.

The previous implementation called fetch, buffered the entire archive into a blob in memory, created an object URL, and then triggered the download. For large snapshot image archives this is wasteful and risks failing on memory. It also duplicated error handling (403 / 404 / generic) that the browser surfaces on its own when navigating to the endpoint.

By passing the download URL straight to downloadFromHref, the browser streams the response and handles HTTP error statuses directly, so the manual fetch/blob/cleanup and error-branching logic can be removed.

No change to the download endpoint or the success toast behavior.

Simplify snapshot image download to use a direct browser navigation to
the download endpoint instead of fetching the blob in JavaScript. The
previous approach buffered the entire zip in memory before triggering
the download, which is unnecessary and could fail on large archives.

The browser now handles the response directly, including error status
codes, so the manual fetch/blob/error-handling logic is no longer
needed.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jun 3, 2026
@NicoHinderling NicoHinderling marked this pull request as ready for review June 3, 2026 18:21
@NicoHinderling NicoHinderling requested a review from a team as a code owner June 3, 2026 18:21
Comment thread static/app/views/preprod/snapshots/header/snapshotHeaderActions.tsx Outdated
Comment thread static/app/views/preprod/snapshots/header/snapshotHeaderActions.tsx Outdated
downloadFromHref triggers a fire-and-forget browser download, so the
code cannot observe a 403/404/500 response. Showing the "download
started" toast unconditionally claimed success even when the request
failed. Remove the toast and let the browser's native download UI be
the source of truth.

Co-Authored-By: Claude <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 a7e8544. Configure here.

const downloadUrl = `/api/0/organizations/${organizationSlug}/preprodartifacts/snapshots/${data.head_artifact_id}/download/`;

try {
const response = await fetch(downloadUrl, {credentials: 'include'});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Success toast no longer shown

Medium Severity

After starting a snapshot images download, users no longer see the success toast that confirmed the download began. The handler only calls downloadFromHref and removed addSuccessMessage, unlike similar flows such as useDataExport that still toast after triggering a browser download.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a7e8544. Configure here.

@NicoHinderling NicoHinderling merged commit 6e3b0e7 into master Jun 3, 2026
70 checks passed
@NicoHinderling NicoHinderling deleted the ref/snapshot-images-direct-download branch June 3, 2026 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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