Skip to content

Commit 9ab26e1

Browse files
fix(snapshots): Add --project flag for org token compatibility
The latest-base endpoint requires a project query param when using org auth tokens, since they lack user project membership. Forward the existing --project arg to the API call so org tokens work in CI. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a07d193 commit 9ab26e1

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/api/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,7 @@ impl AuthenticatedApi<'_> {
10421042
org: &str,
10431043
app_id: &str,
10441044
branch: Option<&str>,
1045+
project: Option<&str>,
10451046
) -> ApiResult<Option<LatestBaseSnapshotResponse>> {
10461047
let mut path = format!(
10471048
"/organizations/{}/preprodartifacts/snapshots/latest-base/?app_id={}",
@@ -1051,6 +1052,9 @@ impl AuthenticatedApi<'_> {
10511052
if let Some(branch) = branch {
10521053
path.push_str(&format!("&branch={}", QueryArg(branch)));
10531054
}
1055+
if let Some(project) = project {
1056+
path.push_str(&format!("&project={}", QueryArg(project)));
1057+
}
10541058
let resp = self.get(&path)?;
10551059
if resp.status() == 404 {
10561060
Ok(None)

src/commands/snapshots/download.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ pub fn make_command(command: Command) -> Command {
1919
.about("[EXPERIMENTAL] Download baseline snapshot images from Sentry.")
2020
.long_about(format!(
2121
"Download baseline snapshot images from Sentry's preprod system to a local directory.\n\n\
22+
Use --snapshot-id to download a specific snapshot, or --app-id to resolve the latest \
23+
baseline (org auth tokens require --project with a numeric project ID for --app-id).\n\n\
2224
{EXPERIMENTAL_WARNING}"
2325
))
2426
.org_arg()
27+
.project_arg(false)
2528
.arg(
2629
Arg::new("app_id")
2730
.long("app-id")
@@ -60,6 +63,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
6063
let api_ref = Api::current();
6164
let api = api_ref.authenticated()?;
6265

66+
let project = matches.get_one::<String>("project").map(|s| s.as_str());
6367
let app_id = matches.get_one::<String>("app_id");
6468
let snapshot_id_arg = matches.get_one::<String>("snapshot_id");
6569
let branch = matches.get_one::<String>("branch").map(|s| s.as_str());
@@ -72,7 +76,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
7276
let snapshot_id = match (app_id, snapshot_id_arg) {
7377
(Some(app_id), None) => {
7478
eprintln!("Resolving latest baseline snapshot for app '{app_id}'...");
75-
match api.get_latest_base_snapshot(&org, app_id, branch)? {
79+
match api.get_latest_base_snapshot(&org, app_id, branch, project)? {
7680
Some(resp) => {
7781
eprintln!(
7882
"Found snapshot {} ({} images)",

0 commit comments

Comments
 (0)