Skip to content
This repository was archived by the owner on Nov 16, 2026. It is now read-only.
This repository was archived by the owner on Nov 16, 2026. It is now read-only.

Align responseStyle types and stabilize SDK error contracts #94

Closed

Description

@betegon

Part of v1.0.0 getsentry/sentry-api-schema#93. This is the response/error foundation for CLI, MCP, the frontend, and external consumers. Frontend inference and runtime adoption are separate follow-ups: #102 and #103.

Problem

Generated operations accept responseStyle: "data" and return only the parsed body at runtime, but their TypeScript return type still exposes the fields envelope, including response. Code that reads headers therefore typechecks and then fails. This predates the object-client DX change and affects standalone and bound operations.

const result = await listOrganizations({
  baseUrl: "https://example.test",
  responseStyle: "data",
  fetch: async () => Response.json([]),
});

// Currently typechecks, but result is an array and result.response is undefined.
result.response.headers.get("Link");

Contract to settle here

Use fields as the primary public result contract:

// Success
{ data, request, response }

// HTTP failure with throwOnError: false
{ error, request, response }

// A failure without an HTTP response
{ error, request, response: undefined }

These describe the relevant fields; exact discriminant/property optionality must agree between runtime and types. Received headers are response.headers; outgoing headers are request.headers. throwOnError: true rejects on failure without changing the successful result shape.

  • Resolve the currently exposed responseStyle: "data" configuration explicitly: support it with accurate types or constrain/reject it with documented 0.x migration guidance. Do not silently change runtime output to make a type test pass.
  • Make initial config, per-call overrides, and supported setConfig updates agree with runtime/types across bound, standalone, and injected-client operations.
  • Type absent HTTP responses honestly. Preserve status/body/headers for actual responses, including undocumented error statuses.
  • Define consistent default HTTP-error behavior using the existing SentryApiError: returning an error and throwing it should describe the same failure. Preserve original error text and parsed body during the existing body read, with request/response context and causes where applicable. Consumers should not need a WeakMap, response clone, or JSON reserialization to reconstruct error metadata.
  • Respect an intentional consumer error mapping. A returned/custom-thrown error must not be silently replaced by later normalization or pagination. Document interceptor ordering and verify exact error identity where propagation is promised.
  • Keep custom-fetch/application exceptions, cancellation, decoding/validation failures, and HTTP failures distinct. A catch-all must not label every exception as a pre-response network failure.
  • Reconcile existing pagination and typed-error helpers with this contract. Explicit status-narrowing helpers may retain a documented opt-in result contract; they must not be inserted transparently into consumers that chose their own errors. Document any deliberate changes rather than silently redesigning those helpers.
  • Verify runtime and compile-time behavior for success, HTTP errors, absent responses, configuration precedence, custom errors, interceptors, and representative pagination/error helpers. Error-body types remain limited by the schema; a documented status is not runtime payload validation.

What is outside #94

The frontend must be able to keep its real RequestError; #94 provides the stable context and propagation guarantees for a later shared integration. It does not make the SDK responsible for login/SSO/sudo, UI messages, CLI exit codes, or MCP tool responses.

Keep implementation PRs focused. If a remaining error/helper change needs a separate PR, retain a linked unchecked requirement here or in #93; fixing only the type mismatch must not imply the broader contract has shipped.

Following work

  1. #102: generate contracts consumed by existing apiOptions, retaining apiFetch → Client and therefore existing errors/auth/cache. This has no technical dependency on replacing the transport and can progress in parallel.
  2. #103: adopt SDK runtime mechanics in shared infrastructure, supply reusable adaptation from the SDK where needed, and prove actual frontend workflows. This consumes Align responseStyle types and stabilize SDK error contracts #94 and the relevant cancellation/auth/routing contracts.

Investigate generator configuration/post-processing or upstream Hey API before adding another abstraction. The inspected build uses Hey API 0.91.1; recheck the chosen generator version. Typed-error wrappers getsentry/sentry-api-schema#84 currently force fields for their own calls and do not fix direct operations.

Activity

  1. changed the title [-]Align responseStyle return types with runtime results[/-] [+]Align responseStyle types and stabilize SDK error contracts[/+] on Oct 15, 2026
  2. added a commit that references this issue on Oct 15, 2026
    2ae0413
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions