Skip to content

Commit a5b4084

Browse files
fix(snapshots): Respect SENTRY_PROJECT env var in download command
Use config.get_project() instead of reading --project flag directly, so the download command respects SENTRY_PROJECT env var and ini config defaults like the build command does. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0ed473f commit a5b4084

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

src/commands/snapshots/download.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
6363
let api_ref = Api::current();
6464
let api = api_ref.authenticated()?;
6565

66-
let project = matches.get_one::<String>("project").map(|s| s.as_str());
66+
let project = config.get_project(matches).ok();
6767
let app_id = matches.get_one::<String>("app_id");
6868
let snapshot_id_arg = matches.get_one::<String>("snapshot_id");
6969
let branch = matches.get_one::<String>("branch").map(|s| s.as_str());
@@ -76,7 +76,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
7676
let snapshot_id = match (app_id, snapshot_id_arg) {
7777
(Some(app_id), None) => {
7878
eprintln!("Resolving latest baseline snapshot for app '{app_id}'...");
79-
match api.get_latest_base_snapshot(&org, app_id, branch, project)? {
79+
match api.get_latest_base_snapshot(&org, app_id, branch, project.as_deref())? {
8080
Some(resp) => {
8181
eprintln!(
8282
"Found snapshot {} ({} images)",

tests/integration/_cases/snapshots/snapshots-download-help.trycmd

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ $ sentry-cli snapshots download --help
33
? success
44
Download baseline snapshot images from Sentry's preprod system to a local directory.
55

6+
Use --snapshot-id to download a specific snapshot, or --app-id to resolve the latest baseline (org
7+
auth tokens require --project with a numeric project ID for --app-id).
8+
69
[EXPERIMENTAL] The "snapshots download" command is experimental. The command is subject to breaking
710
changes, including removal, in any Sentry CLI release.
811

@@ -12,36 +15,39 @@ Options:
1215
-o, --org <ORG>
1316
The organization ID or slug.
1417

15-
--app-id <APP_ID>
16-
App identifier (e.g. sentry-frontend). Mutually exclusive with --snapshot-id.
17-
1818
--header <KEY:VALUE>
1919
Custom headers that should be attached to all requests
2020
in key:value format.
2121

22+
-p, --project <PROJECT>
23+
The project ID or slug.
24+
25+
--app-id <APP_ID>
26+
App identifier (e.g. sentry-frontend). Mutually exclusive with --snapshot-id.
27+
2228
--auth-token <AUTH_TOKEN>
2329
Use the given Sentry auth token.
2430

31+
--log-level <LOG_LEVEL>
32+
Set the log output verbosity. [possible values: trace, debug, info, warn, error]
33+
2534
--snapshot-id <ID>
2635
Direct snapshot artifact ID. Mutually exclusive with --app-id.
2736

2837
--branch <NAME>
2938
Git branch filter (only with --app-id).
3039

31-
--log-level <LOG_LEVEL>
32-
Set the log output verbosity. [possible values: trace, debug, info, warn, error]
33-
34-
--output <DIR>
35-
Directory for extracted images.
36-
37-
[default: ./snapshots-base/]
38-
3940
--quiet
4041
Do not print any output while preserving correct exit code. This flag is currently
4142
implemented only for selected subcommands.
4243

4344
[aliases: --silent]
4445

46+
--output <DIR>
47+
Directory for extracted images.
48+
49+
[default: ./snapshots-base/]
50+
4551
-h, --help
4652
Print help (see a summary with '-h')
4753

0 commit comments

Comments
 (0)