Skip to content

fix(httpapi): expose v2 request errors#28495

Merged
nexxeln merged 1 commit into
devfrom
nxl/v2-error-contracts
May 20, 2026
Merged

fix(httpapi): expose v2 request errors#28495
nexxeln merged 1 commit into
devfrom
nxl/v2-error-contracts

Conversation

@nexxeln
Copy link
Copy Markdown
Member

@nexxeln nexxeln commented May 20, 2026

summary

  • add v2-only authorization errors with response bodies while preserving legacy auth middleware
  • return InvalidRequestError/InvalidCursorError for v2 schema, workspace, and cursor failures
  • tighten OpenAPI guardrails for /api/* built-in endpoint errors

testing

  • bun test test/server/httpapi-authorization.test.ts test/server/httpapi-schema-error-body.test.ts test/server/httpapi-session.test.ts test/server/httpapi-public-openapi.test.ts
  • bun typecheck
  • push hook: bun turbo typecheck

@nexxeln nexxeln merged commit 40e73c4 into dev May 20, 2026
9 of 11 checks passed
@nexxeln nexxeln deleted the nxl/v2-error-contracts branch May 20, 2026 17:53
kitlangton added a commit to kitlangton/opencode that referenced this pull request May 20, 2026
Two problems surfaced when anomalyco#28495 + the follow-up `chore: generate`
populated previously-empty v2 error response unions.

1. `@hey-api/openapi-ts` codegen passes the endpoint's `TError` into the
   second generic of `ServerSentEventsResult`, which is the underlying
   `AsyncGenerator`'s `TReturn` slot — not an error channel. The SSE
   implementation's own signature uses `ServerSentEventsResult<TData>`,
   so it's only the public `SseFn` wrapper that's wrong. Latent for ~9
   months; harmless while error unions were unknown, but breaks every
   `.return(undefined)` call and every mock async generator the moment
   an SSE endpoint declares a concrete error response. Patch the
   generated `client/types.gen.ts` and add a post-gen step in
   `script/build.ts` so every future `chore: generate` reapplies it.
2. `experimental.workspace.warp` now returns `InvalidRequestError` in
   its 400 union, which uses `_tag` rather than `name` as its
   discriminator. Narrow the error before reading `.name` in
   `dialog-workspace-create.tsx`.

Verified end-to-end: `bun run build` in `packages/sdk/js` wipes and
regenerates v2/gen, then re-applies the SseFn patch automatically;
full monorepo typecheck and stream.transport tests are green.
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.

1 participant