Skip to content

feat(snapshots): Follow the server-selected objectstore usecase - #1587

Open
NicoHinderling wants to merge 3 commits into
mainfrom
feat/snapshots-objectstore-usecase
Open

NicoHinderling wants to merge 3 commits into
mainfrom
feat/snapshots-objectstore-usecase

Conversation

@NicoHinderling

@NicoHinderling NicoHinderling commented Sep 14, 2026

Copy link
Copy Markdown

Snapshot uploads now request usecase=auto from the upload-options endpoint and use the server's returned usecase for both HEAD deduplication checks and PUT uploads, rather than hardcoding preprod. This keeps Objectstore paths aligned with the minted token and lets the backend move new snapshot content into preprod_snapshots without another CLI change.

When older servers omit usecase, response parsing defaults it to preprod, preserving the existing upload behavior. Object keys remain unchanged; because deduplication is scoped by usecase, the first upload after a server-side switch re-uploads images once.

Pairs with getsentry/sentry#124194 (cross-usecase reads and the upload-options contract) and getsentry/sentry#124210 (server-controlled write selection). getsentry/sentry-cli#3408 implements the same contract in the legacy CLI; both clients are being updated. The backend option remains off by default: register preprod_snapshots in Objectstore before deploying the backend prerequisite, then enable the option only after the backend rollout. Older CLI releases keep writing to preprod and remain readable through fallback reads.

Request automatic usecase selection for snapshot uploads and use the returned value for
both existence checks and uploads. Default to preprod when older servers omit the field.

Refs getsentry/sentry#124194, getsentry/sentry#124210
@vercel

vercel Bot commented Sep 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Sep 14, 2026 6:28pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Sep 14, 2026 6:28pm UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – sentry-local September 14, 2026 18:09 Inactive
@NicoHinderling
NicoHinderling marked this pull request as ready for review September 14, 2026 18:18
nullish,
number,
object,
optional,

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.

Bug: The schema for fetchSnapshotsUploadOptions uses optional() for the usecase field, which will throw an error if the API returns null instead of defaulting as intended.
Severity: MEDIUM

Suggested Fix

Change the schema validation for the usecase field from optional(string(), "preprod") to nullish(string(), "preprod"). This will correctly handle both null and undefined values by applying the default value, making the code more defensive and consistent with codebase patterns.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: packages/cli/src/lib/api/preprod-artifacts.ts#L26

Potential issue: The schema validation for the response in `fetchSnapshotsUploadOptions`
uses `valibot`'s `optional(string(), "preprod")` for the `usecase` field. This correctly
handles cases where the field is `undefined` (omitted), but it will throw a validation
error if the API explicitly returns `null` for this field. This is inconsistent with
other fields in the same schema and the codebase's documented best practice to use
`.nullish()` for optional fields. If the server returns `"usecase": null`, the
validation will fail, and the unhandled error will crash the entire snapshot upload
command.

Did we get this right? 👍 / 👎 to inform future reviews.

NicoHinderling added a commit to getsentry/sentry that referenced this pull request Sep 14, 2026
…124194)

Prepares snapshot storage to move from the shared `preprod` Objectstore
usecase into `preprod_snapshots`. This PR registers the new usecase and
adds cross-usecase reads, HEAD checks, and deletes through
`SnapshotStorage`. Writes remain on `preprod`, so this deploy does not
move stored content or change the write destination. The fallback metric
records when reads use the secondary usecase.

The upload-options endpoint also accepts `usecase=auto` and echoes the
chosen usecase in its response. Requests without the parameter keep
receiving `preprod` tokens for compatibility with existing CLI releases.
getsentry/sentry-cli#3408 and getsentry/cli#1587 opt into this contract;
#124210 adds the default-off option that selects `preprod_snapshots` for
new writes.

Register `preprod_snapshots` in the Objectstore service configuration
**before deploying this prerequisite**: fallback reads may access it
whenever an object is missing from `preprod`. Deploy the backend stack
fully before enabling the write-selection option. No content-copy
migration is required; existing uploads remain readable through the
fallback.
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