Skip to content

feat(snapshots): Add download command for baseline snapshots#3310

Open
NicoHinderling wants to merge 1 commit into
feat/snapshots-difffrom
feat/snapshots-download
Open

feat(snapshots): Add download command for baseline snapshots#3310
NicoHinderling wants to merge 1 commit into
feat/snapshots-difffrom
feat/snapshots-download

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

Summary

  • Adds sentry-cli snapshots download command for downloading baseline snapshot images from Sentry's preprod system to a local directory
  • Supports --app-id (resolves latest baseline snapshot) or --snapshot-id (direct artifact ID), with optional --branch filter
  • Downloads a ZIP from the server and extracts images to --output directory (default ./snapshots-base/)
  • Adds two API methods: get_latest_base_snapshot and download_snapshot_zip

Usage

# Download latest baselines for an app
sentry-cli snapshots download --app-id sentry-frontend -o ./snapshots-base/

# Download from a specific branch
sentry-cli snapshots download --app-id sentry-frontend --branch main -o ./snapshots-base/

# Download a specific snapshot by ID
sentry-cli snapshots download --snapshot-id 259299 -o ./snapshots-base/

# Full local visual regression workflow
sentry-cli snapshots download --app-id sentry-frontend -o ./snapshots-base/
pnpm run snapshots
sentry-cli snapshots diff ./snapshots-base .artifacts/snapshots --fail-on-diff

Test plan

  • cargo clippy -- -Dwarnings passes clean
  • cargo fmt --check passes
  • cargo test snapshots — all 4 integration tests pass (including new download help test)
  • Manual test: run sentry-cli snapshots download --app-id sentry-frontend against real Sentry org

🤖 Generated with Claude Code

@NicoHinderling NicoHinderling requested review from a team and szokeasaurusrex as code owners May 21, 2026 19:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against a218cba

Comment thread src/commands/snapshots/download.rs Outdated
Comment thread src/commands/snapshots/download.rs Outdated
Comment thread src/commands/snapshots/download.rs Outdated
@NicoHinderling NicoHinderling force-pushed the feat/snapshots-download branch from f391865 to affb90b Compare May 21, 2026 20:32
Comment thread src/api/mod.rs
Comment thread src/api/mod.rs
@NicoHinderling NicoHinderling force-pushed the feat/snapshots-download branch from affb90b to 8783c35 Compare May 21, 2026 20:42
Copy link
Copy Markdown

@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 8783c35. Configure here.

Comment thread src/api/mod.rs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@NicoHinderling NicoHinderling force-pushed the feat/snapshots-download branch from 8783c35 to a218cba Compare May 21, 2026 21:00
Copy link
Copy Markdown

@cameroncooke cameroncooke left a comment

Choose a reason for hiding this comment

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

sentry-cli snapshots download returns 404 when using an org auth token

The snapshots download command fails with No baseline snapshot found even when a base snapshot clearly exists in the UI.

Root cause: The endpoint GET /api/0/organizations/{org}/preprodartifacts/snapshots/latest-base/ calls get_filter_params(), which — when no project= query param is supplied — falls back to "projects the caller is a member of." Org auth tokens (sntrys_*) aren't associated with a user, so they have no project membership, and the call short-circuits to NoProjects → 404. The user never sees a distinct error; it looks identical to "snapshot doesn't exist."

Confirmed: Adding &project=<id> to the same request returns the snapshot successfully — org tokens satisfy has_project_access via their scopes, just not the membership path.

Fix options:

  1. CLI side: Add a --project flag to sentry-cli snapshots download and forward it as project=<id>. Matches
    the convention used by build upload and other commands. Smallest change, works in CI.
  2. Server side: When no project= is supplied, fall back to scoping by organization_id only (the endpoint already orders by -date_added and filters by app_id). Risk: app_id collisions across projects within an org become possible.

@cameroncooke
Copy link
Copy Markdown

Just wondering if we can add support to include JSON sidecar files too?

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