Skip to content

fix(server): map Account failures to typed 500 instead of defect#26448

Merged
kitlangton merged 1 commit into
devfrom
kit/httpapi-account-error-mapping
May 9, 2026
Merged

fix(server): map Account failures to typed 500 instead of defect#26448
kitlangton merged 1 commit into
devfrom
kit/httpapi-account-error-mapping

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • `/experimental/console` and `/experimental/console/orgs` previously piped `account.orgsByAccount()` through `Effect.orDie`. That converted typed `AccountServiceError` into a defect, so the runtime serialized it as a 500 with the raw stack trace embedded in the response body, and any future error middleware that wants to distinguish account failures from other 500s saw only an opaque defect.
  • Replaces `Effect.orDie` with `Effect.catch` mapping to `HttpApiError.InternalServerError`, and declares `InternalServerError` on the endpoint schemas.
  • Wire response is still 500, but the body is the structured HttpApi error shape (no stack-trace leak) and the failure stays on the typed channel.

Test plan

  • `bun run test test/server/httpapi-account-error-mapping.test.ts` (2 pass, behavioral)
  • `bun run test test/server/httpapi-experimental.test.ts` (no regression)

@kitlangton kitlangton force-pushed the kit/httpapi-doc-route-json-response branch from 0f255af to edf91a8 Compare May 9, 2026 02:56
@kitlangton kitlangton force-pushed the kit/httpapi-account-error-mapping branch from 1a71f21 to fa6504b Compare May 9, 2026 02:56
@kitlangton kitlangton force-pushed the kit/httpapi-doc-route-json-response branch from edf91a8 to 15779da Compare May 9, 2026 03:02
@kitlangton kitlangton force-pushed the kit/httpapi-account-error-mapping branch from fa6504b to 2cd4bf8 Compare May 9, 2026 03:02
@kitlangton kitlangton force-pushed the kit/httpapi-doc-route-json-response branch from 15779da to 1df6d83 Compare May 9, 2026 03:07
@kitlangton kitlangton closed this May 9, 2026
@kitlangton kitlangton force-pushed the kit/httpapi-account-error-mapping branch from 2cd4bf8 to 1df6d83 Compare May 9, 2026 03:07
@kitlangton kitlangton reopened this May 9, 2026
@kitlangton kitlangton force-pushed the kit/httpapi-doc-route-json-response branch from 4942d9a to 3ca5a02 Compare May 9, 2026 03:13
@kitlangton kitlangton force-pushed the kit/httpapi-account-error-mapping branch from 751ab84 to b30384a Compare May 9, 2026 03:13
@kitlangton kitlangton force-pushed the kit/httpapi-doc-route-json-response branch from 3ca5a02 to c2855a3 Compare May 9, 2026 03:19
@kitlangton kitlangton force-pushed the kit/httpapi-account-error-mapping branch from b30384a to d799e48 Compare May 9, 2026 03:19
@kitlangton kitlangton force-pushed the kit/httpapi-doc-route-json-response branch from c2855a3 to 3076f21 Compare May 9, 2026 03:40
@kitlangton kitlangton force-pushed the kit/httpapi-account-error-mapping branch from d799e48 to c931995 Compare May 9, 2026 03:40
@kitlangton kitlangton changed the base branch from kit/httpapi-doc-route-json-response to dev May 9, 2026 03:40
The /experimental/console and /experimental/console/orgs handlers
previously piped account.orgsByAccount() through Effect.orDie. That
converts typed AccountServiceError into a defect, so the runtime
serializes it as a 500 with the raw stack trace embedded in the
response body — and any future error middleware that wants to
distinguish account failures from other 500s sees only an opaque
defect.

Replace Effect.orDie with Effect.catch mapping to
HttpApiError.InternalServerError, and declare InternalServerError on
the endpoint schemas. The wire response is still 500, but the body is
the structured HttpApi error shape (no stack-trace leak) and the
failure stays on the typed channel for downstream handlers to inspect.
@kitlangton kitlangton force-pushed the kit/httpapi-account-error-mapping branch from c931995 to 8d4bea4 Compare May 9, 2026 03:41
@kitlangton kitlangton merged commit 3615d5a into dev May 9, 2026
6 of 8 checks passed
@kitlangton kitlangton deleted the kit/httpapi-account-error-mapping branch May 9, 2026 03:44
katosun2 pushed a commit to katosun2/opencode that referenced this pull request May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant