feat(snapshots): Add download command for baseline snapshots#3310
Conversation
|
f391865 to
affb90b
Compare
affb90b to
8783c35
Compare
8783c35 to
a218cba
Compare
cameroncooke
left a comment
There was a problem hiding this comment.
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:
- CLI side: Add a
--projectflag tosentry-cli snapshots downloadand forward it asproject=<id>. Matches
the convention used bybuild uploadand other commands. Smallest change, works in CI. - Server side: When no
project=is supplied, fall back to scoping byorganization_idonly (the endpoint already orders by-date_addedand filters byapp_id). Risk:app_idcollisions across projects within an org become possible.
|
Just wondering if we can add support to include JSON sidecar files too? |
41af7fd to
0d88866
Compare
thanks for flagging this, i've addressed this now |
I think lets hold off on this for now, since this use case is pretty specific for local diffing |
730c411 to
9ab26e1
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
9ab26e1 to
e66e51c
Compare
1c7b0cc to
3ce0749
Compare
e66e51c to
e790a06
Compare
3ce0749 to
999c951
Compare
f6c00bd to
a5b4084
Compare
szokeasaurusrex
left a comment
There was a problem hiding this comment.
mostly looks good, but please address the comments about tempfile before merging.
This should also be reviewed by someone from Emerge to make sure that the endpoints and any logic specific to the snapshots features are correct, I mainly checked the general structure.
cf94ea1 to
a70417b
Compare
a5b4084 to
97998d3
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 97998d3. Configure here.
There was a problem hiding this comment.
Looks good, though I only skimmed the changes, as they are mostly related to the Emerge functionality. Please have someone from the Emerge team also review and approve especially the downloading logic before merging
Edit: looks like @cameroncooke already approved 😄
|
@NicoHinderling this might be an issue: When --project is omitted (and SENTRY_PROJECT / .sentryclirc don't supply one either), the CLI hits latest-base with
So you can be perfectly entitled to a baseline snapshot, with one sitting in a project you own, and still get "no It's also possible that an iOS and Android project exists with same app id, but you only have project access to one of them. |
97998d3 to
c71df16
Compare
i recall this concern coming up in my own personal reviews and don't think it's that common of a case, so i'm opting to ignore this for now until a user reports hitting it |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c71df16 to
a33edf2
Compare
Removes the `tar` crate from runtime dependencies — it was added but never used anywhere in the source. Only `zip::ZipArchive` is needed for snapshot extraction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
just kidding im a great guy and did it after all getsentry/sentry#116319 |
#17903) ## DESCRIBE YOUR PR Documents the new `sentry-cli snapshots download` and `sentry-cli snapshots diff` commands added in [sentry-cli#3306](getsentry/sentry-cli#3306) and [sentry-cli#3310](getsentry/sentry-cli#3310). - New "Local Testing" product docs page covering the workflow: download baselines → run tests → diff locally - CLI reference sections for `snapshots download` and `snapshots diff` with flag tables ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): - [x] Other deadline: - [ ] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) --------- Co-authored-by: Claude <noreply@anthropic.com>


Summary
sentry-cli snapshots downloadcommand for downloading baseline snapshot images from Sentry's preprod system to a local directory--app-id(resolves latest baseline snapshot) or--snapshot-id(direct artifact ID), with optional--branchfilter--outputdirectory (default./snapshots-base/)get_latest_base_snapshotanddownload_snapshot_zipUsage
Test plan
cargo clippy -- -Dwarningspasses cleancargo fmt --checkpassescargo test snapshots— all 4 integration tests pass (including new download help test)sentry-cli snapshots download --app-id sentry-frontendagainst real Sentry org🤖 Generated with Claude Code