Skip to content

ref(api): Read and write Objectstore batches with FormData - #131779

Merged
BYK merged 1 commit into
masterfrom
byk/feat/api-objectstore-formdata
Nov 20, 2026
Merged

BYK merged 1 commit into
masterfrom
byk/feat/api-objectstore-formdata

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

The @sentry/api Objectstore client (used by the Sentry CLI's snapshots upload) had its own byte-level multipart encoder and parser for the batch endpoint, because all per-operation data travelled in custom part headers that FormData drops. Objectstore now has a JSON layout for batches that carries that data in form fields instead (getsentry/objectstore#769, getsentry/objectstore#804, thanks @jan-auer). This switches the client to it:

  • Requests are a FormData: each operation is a JSON descriptor field named by its index ({"kind":"head","key":"…"}), and each insert also gets a "<i>.payload" file holding the bytes. The expiration policy moves from the x-sn-expiration part header to metadata.expiration. fetch sets the multipart Content-Type and boundary.
  • Responses are read with Response.formData(). Each result is a JSON field named by its operation index ({"status":404,…}, with error.detail on failure). Fields that aren't results, such as GET payloads, are skipped. A multipart response that can't be parsed throws an ObjectstoreError (502), the same as a response that isn't multipart.
  • Keys go into JSON unescaped. encodeHeaderValue, the boundary regex, and the byte-scanning helpers are removed.

The public API (findExistingObjects, putObjects, ObjectstoreError) doesn't change. Single-object PUTs for files over 1 MB don't change either. All part names are quoted, so Node 22's Response.formData() (undici before 7.17) can parse responses too.

Open question before merge: the client no longer speaks the header layout, so it needs an Objectstore server that has getsentry/objectstore#804. A server without it would fail every batch operation. Please confirm that the production Objectstore behind the Sentry proxy runs a build with #804 before this ships in an @sentry/api release.

via @BYK.

--

View Session [Sentry]

Objectstore's batch endpoint now has a JSON layout that carries all
operation data in form fields (getsentry/objectstore#804). Build batch
requests with FormData and read results with Response.formData(),
replacing the hand-rolled multipart encoder and parser.

Refs getsentry/objectstore#769

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 19, 2026
@BYK
BYK marked this pull request as ready for review November 20, 2026 20:03
@BYK
BYK requested review from a team as code owners November 20, 2026 20:03
@sentry-junior
sentry-junior Bot requested a review from BYK November 20, 2026 20:03

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! I also got a note here from the authors:

We’re also disabling compression now for PNGs because it doesn’t make sense

And ref: getsentry/sentry-cli#3504

@BYK
BYK merged commit f6cef76 into master Nov 20, 2026
81 checks passed
@BYK
BYK deleted the byk/feat/api-objectstore-formdata branch November 20, 2026 20:04
sentry-junior Bot added a commit to getsentry/toolkit that referenced this pull request Nov 26, 2026
@sentry/api 3.0.0 includes getsentry/sentry#131779, which sends and
reads Objectstore batches as FormData: one JSON part per operation,
named by its index, with an insert's bytes in `<index>.payload`. The
CLI's objectstore tests still built responses with the old
`x-sn-batch-operation-*` part headers, which the new parser rejects.
BYK added a commit to getsentry/toolkit that referenced this pull request Nov 26, 2026
…ok (#2542)

Bumps `@sentry/api` to 3.0.0 and moves the CLI and MCP retries onto the
transport's new `retry` hook, added in getsentry/sentry#132687.

### What changes
- **toolkit-core:** `withSentryRetry` and `TRANSPORT_SENDS_ONCE` are
replaced by `sentryRetry(options): TransportRetry`. It builds the hook
on `@sentry/http`'s `fetchWithRetry`, using `SENTRY_RETRYABLE_STATUSES`
and `@sentry/api`'s `parseRetryDelayMs`. `SentryRetryOptions` takes
`policy`, `isRetryableError`, and an `onRetry` that also gets the
retried request's method and URL.
- **CLI and MCP:** both pass `retry: sentryRetry({ policy })` to
`createApiTransport` instead of wrapping `transport.request`. The
transport now runs the hook after the cache lookup and the credential's
`prepare`. A retried request looks up the cache and the credential once,
and it gets one host span instead of one per attempt. Each attempt still
has its own timeout, body buffering, redirect checks, and 401 refresh,
and the refresh doesn't count as a retry.
- **Idempotency:** the hook gets `idempotent` from the transport, which
already combines the per-request flag with the operation catalog
(`isIdempotent`). So the wrapper's separate `isIdempotent` option goes
away.
- **CLI `isRetryableError`:** the `TimeoutError` case is gone. An
attempt now throws the transport's `ApiTimeoutError`, which isn't a
`CliError`, so it still retries. `errors.timeout` maps the final timeout
to `TimeoutError` once, after the hook gives up.
- **MCP issue-event read:** 3.0.0 types `event_id` as a string, so the
cast for 32-character event IDs is removed. Without it, lint fails with
an unnecessary-assertion error.
- **`pnpm-workspace.yaml`:** the catalog entry and the
`minimumReleaseAgeExclude` entry move to `@sentry/api@3.0.0`.

### Also picked up from 2.16.0
The bump from 2.15.0 includes getsentry/sentry#131779, which sends and
reads Objectstore batches as FormData. Each operation is a JSON part
named by its index, and an insert's bytes go in `<index>.payload`. The
CLI's snapshot uploads use that batch client, so their wire format
changes with this PR. The CLI's objectstore test fixtures now build
responses in that format.

`@sentry/http` needs no new export: `fetchWithRetry(send, options)`
already fits the hook.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A672bf07a67118adf395d2ead4a7cd9aa -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3A672bf07a67118adf395d2ead4a7cd9aa)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A672bf07a67118adf395d2ead4a7cd9aa/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <126780+BYK@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — fb733963 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant