Repository navigation
Description
Part of v1.0.0 getsentry/sentry-api-schema#93. Follow #102's generated-contract/apiOptions phase with a real SDK runtime integration in shared frontend infrastructure.
Updated 2026-11-14: @sentry/api now lives in the same repository as the frontend, getsentry/sentry, under static/packages/api. It releases from there as [email protected], and the current version is 2.5.0. Do new SDK and frontend work for this issue in getsentry/sentry.
What exists now
- Operations catalog:
@sentry/api/operationslists every generated operation with its function name, method, path, query metadata, andexperimental/idempotentflags, without importing the client. - Reference data:
@sentry/api/docsexports per-operation parameters, request bodies, responses and examples for rendering API reference pages. - Response/error contract: the error handling contract from fix: stabilize SDK response and error contracts sentry-api-schema#104 keeps the parsed body, original text, request and response metadata, and leaves custom errors, decoding failures and cancellation unchanged through operations and pagination.
- Cancellation: per-operation signals, covered by
test/cancellation.test.ts(Fixed CSRF problem with AJAX POST requests #95 is closed). - Retries: the shared client's
createApiTransportretries throughlib/api-client/retry.ts(message_id collisions in sentry #92 is closed). - Root entry: no React, TanStack or validator dependency;
zodandvalibotare optional peers (package.json). - Not done yet: the type-level operation map for
apiOptionsis still open in #102, and the frontend does not use the SDK runtime yet.
Outcome
A migrated query must require no more infrastructure code than today's apiOptions call. Keep the actual frontend RequestError, existing imports, query keys, selectors, and {json, headers, status?} cache contract. Do not require retiring RequestError as a condition of adopting the SDK.
apiOptions / infinite options
↓
shared frontend execution + SDK integration
↓
SDK HTTP mechanics + retained frontend policies
↓
success: {json, headers, status?}
failure: the frontend's actual RequestError where applicable
What we maintain in the SDK
- Supply and test the reusable response/error adaptation once, on top of the existing error contract and without consumer-side cloning or a WeakMap. If a frontend-specific compatibility module is needed, keep it optional and preserve the real frontend error class through the smallest typed seam validated by the pilot; do not import Sentry application code into the core or duplicate its error class.
- Reuse existing interception/composition mechanisms where sufficient. Settle the smallest public integration API from the pilot; names such as
installRequestErrorAdapter,apiOptions.sdk, andcreateFrontendCompatibilitywere sketches, not accepted APIs.
What stays with the frontend
Reuse its existing policies centrally: login/SSO, allowAuthError, sudo and its explicit retry, project redirects, regional/admin/dev routing context, credentials/CSRF decisions, telemetry, forms, user messages, and query-cache lifecycle. Feature components should not implement this adaptation.
Keeping the error class alone does not preserve these behaviors: they currently execute inside Client before the error reaches TanStack. Keep or extract that shared policy seam instead of copying the entire frontend client into the SDK with many callbacks.
The current Client.requestPromise() returns parsed data and ResponseMeta, not a native Response. Its raw fetch promise is also consumed by the client's own body parser and precedes sudo handling. Do not treat either as a drop-in Fetch adapter or reconstruct native responses by JSON stringify/parse.
Routing integration
Build on #81's metadata-driven contract in shared frontend infrastructure. Keep apiOptions and use organization locality from the existing bootstrap-populated ConfigStore; no discovery or adaptation in ordinary component queries.
- Scope known
regionUrlto its organization. Preserve explicit-host precedence, multi-region-disabled behavior, admin proxy routing, development URL rewrites and the org-domain dev proxy (which must not use the last organization's locality). - Keep control operations on control even when their path contains an organization. For operations available in both contexts, preserve intended control/local semantics rather than treating hosts as equivalent.
- Retain the existing adapter for private/unsupported routes. Public OpenAPI metadata does not replace the frontend's entire internal route catalog.
- Keep ConfigStore in page memory; do not copy it into a second SDK discovery cache. SDK-managed discovery remains separately opt-in.
- Verify the final destination before attaching browser credentials/CSRF. Preserve body, headers, status, signal, actual RequestError behavior and request counts.
- Test a regional read, control request, cross-organization/admin request and development proxy flow centrally, with no per-component host selection.
Backend metadata and the SDK routing foundation precede this runtime adoption. getsentry/sentry-api-schema#102 remains independent; Toolkit #1502 does not need to merge before this shared contract is settled.
Pilot and acceptance
- Integrate one query and one related mutation centrally. Preserve request/response metadata, field errors, and exact
RequestErroridentity where that class is produced; no converter in each component. - A 403 still follows the existing non-retry policy; 404 handling, localized messages, and form-field errors retain their behavior. Test network/decoding failures separately rather than pretending every error has one class.
- Verify login/SSO and
allowAuthError; sudo must preserve the final retry's actual status/headers. A normalized HTTP error must not accidentally bypass these flows. - Preserve
Link, numeric hit counts,X-Sentry-Direct-Hit, and status. Verify existing cache readers/writers, optimistic updates, invalidation, and selectors. - Validate a table and an infinite query with Define a shared, opinionated pagination API for v1 sentry-api-schema#99: URL cursors/filter resets, next/previous pages, prefetch, and specialized
pageParambehavior. TanStack owns page state; do not substitutepaginateAll()for incremental fetching. - Wire TanStack's signal through the shared path, using the SDK's per-operation signal support. Distinguish cancellation from failures requiring UI/retry; do not replicate legacy indefinitely pending promises as a new SDK guarantee.
- Keep one retry owner. Preserve the frontend's TanStack policy by default; composing the SDK's retrying transport must not multiply attempts.
- Preserve private/unsupported endpoint fallback and deployment/admin/dev routing behavior. No whole-frontend rewrite is required.
- Link implementation PRs and results to v1.0.0 sentry-api-schema#93. Distinguish type-only adoption, mocked tests, and real integrated browser/deployment validation.
Sequence and evidence
The generated-contract phase can improve apiOptions before this runtime migration. The getsentry/sentry-api-schema#94 response/error, getsentry/sentry-api-schema#95 cancellation and getsentry/sentry-api-schema#92 retry contracts are now in the package; this phase still depends on the auth/browser/routing contracts in #131198. Deliver SDK support and frontend integration in focused PRs.
A local mocked probe already demonstrated that an SDK error interceptor can produce the real frontend RequestError, TanStack stores that same object, and the current 403 retry policy performs only one request. That is feasibility evidence only; it does not validate this full integration, SSO/sudo, cancellation, or a deployed browser.
An optional generic TanStack binding remains useful for external applications. It is separate from preserving Sentry's existing apiOptions conventions and is not a prerequisite for the first frontend phase. Type-only adoption does not satisfy getsentry/sentry-api-schema#93's required runtime frontend workflow.
via @BYK.
--
Activity
fix: stabilize SDK response and error contracts (#104)
fix: preserve cancellation before SDK fetch dispatch (#105)
linear-code commentedon Nov 16, 2026
ENG-9055
feat(api): Match a method and concrete path to a catalog operation (#…
feat(api): Read Sentry's list headers and keep Link targets (#131242)
fix(api): Send the browser CSRF token only to similar origins (#131230)
feat(api): Add getSentryApiErrorDetails for mapping SDK errors (#131249)
fix(api): Send the browser CSRF token only over https from https pages (
feat(apidocs): Publish the SentryAPIException error body as a compone…
feat(apidocs): Mark auth-challenge error codes in the error component (…
feat(api): Generate error codes and challenge fields from the spec (#…
feat(api): Know per-operation error codes and read top-level codes (#…
ref(api): Drop the isRecord guard from SentryApiError body reads (#13…
docs(api): Say which entries import p-limit and http-cache-semantics (#…
feat(api): Report renamed projects with getSentryProjectRename (#131258)
feat(api): Make the query-string@7 serializer the default (#131247)
ref(api): Note that matchOperation doesn't support path prefixes (#13…