Skip to content

fix(server): return structured validation errors#26457

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

fix(server): return structured validation errors#26457
kitlangton merged 1 commit into
devfrom
kit/httpapi-validation-error-body

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

  • Convert HttpApi schema validation failures into the documented structured 400 body.
  • Add representative sync validation coverage for JSON error content.

Test

  • bun test --timeout 5000 test/server/httpapi-authorization.test.ts test/server/httpapi-instance.test.ts test/server/httpapi-sync.test.ts
  • bun typecheck

@kitlangton kitlangton force-pushed the kit/httpapi-request-id-validation branch from d35105c to 9a2ad7b Compare May 9, 2026 04:12
@kitlangton kitlangton force-pushed the kit/httpapi-validation-error-body branch from 3c058c7 to 6226390 Compare May 9, 2026 04:12
@kitlangton kitlangton force-pushed the kit/httpapi-request-id-validation branch from 9a2ad7b to 528dcf1 Compare May 9, 2026 04:17
@kitlangton kitlangton force-pushed the kit/httpapi-validation-error-body branch from 6226390 to c304394 Compare May 9, 2026 04:17
Base automatically changed from kit/httpapi-request-id-validation to dev May 9, 2026 04:20
@kitlangton kitlangton force-pushed the kit/httpapi-validation-error-body branch from c304394 to 6e91ea0 Compare May 9, 2026 04:20
@kitlangton kitlangton marked this pull request as ready for review May 9, 2026 04:21
@kitlangton kitlangton merged commit ebe6087 into dev May 9, 2026
6 of 8 checks passed
@kitlangton kitlangton deleted the kit/httpapi-validation-error-body branch May 9, 2026 04:21
kitlangton added a commit that referenced this pull request May 9, 2026
PR #26457 changed the 400 wire format on the HTTP API in three ways:
1. \`Effect.catch(HttpApiError.BadRequest)\` → \`{ data: {}, errors: [], success: false }\`
2. \`HttpApiSchemaError\` defect → same shape
3. \`normalizeEmptyBadRequest\` post-processor that rewrites ANY empty
   400 into the same shape

In v1.14.42 (post-Hono-deletion) at least one external plugin
(\`opencode-gemini-auth\`, per #26546 reports) makes an HTTP API call
during startup that hits one of these paths and breaks on the new
body shape — the unparseable JSON ends up printed to stdout and the
TUI never starts. \`opencode --pure\` works (no plugins), \`opencode run\`
works (no in-process server interaction), but \`opencode\` (TUI) crashes.

Revert all three changes from #26457. The default HttpApi serialization
of typed errors comes back, matching v1.14.41 wire format. We can
re-introduce structured validation responses behind an opt-in or
contract change once plugin authors have a chance to migrate.

Closes #26546.
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