fix: type plain onError return as error status response - #1966
fix: type plain onError return as error status response#1966zacharywomack8-source wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review. WalkthroughThis change adds error-handler-specific response inference types. It applies them to ChangesError response inference
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This PR corrects the reported type mismatch for plain values returned by error handlers while preserving explicit status handling; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
da62021 to
b16c93b
Compare
@algora-pbc /claim #313
Type-level fix for #313 (Option to return errors as JSON).
Problem
An onError handler that returns a plain value (e.g.
{ error: '...' }or a string) is currently typed as if the response is200. At runtime the response keeps the status of the error that triggered the handler (400/404/422/500), so the types lie about what the client receives.Change
onErrorare now typed under every built-in error status (400,404,422,500) instead of200.status(code, ...)/error(code, ...)returns still resolve to their exact status code viaExtractErrorFromHandle.onError(single handler and array overloads), plusErrorHandlecomposition inuse/guard/macro.Implementation
ErrorValueToResponseSchema,ElysiaErrorHandlerToResponseSchema,ElysiaErrorHandlerToResponseSchemas,ElysiaErrorHandlerToResponseSchemaAmbiguousinsrc/types.ts.onErroroverloads and theErrorHandleguards insrc/index.ts.Verification
test/types/lifecycle/soundness.tsonError expectations: plain returns now produce the error-status union instead of200.pnpm test:typespasses.Summary by CodeRabbit
claim-recheck-marker