-
-
Notifications
You must be signed in to change notification settings - Fork 462
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What is the problem this feature would solve?
Currently, when the response does not conform to the provided schema,
a 422 HTTP status code (Unprocessable Entity) is returned.
Reproduction
import Elysia from "elysia";
import { z } from "zod";
export const app = new Elysia()
.get(
"/api-keys",
(ctx) => {
return {
keys2: [],
};
},
{
response: {
200: z.strictObject({
keys: z.array(z.unknown()),
}),
},
}
)
.listen(3000);-
Start the server
-
Perform a request
curl -i http://localhost:3000/api-keys
-
Check response status code:
HTTP/1.1 422 Unprocessable Entity Content-Type: application/json Date: Tue, 14 Oct 2025 09:49:55 GMT Content-Length: 519 # omitted for brevity
What is the feature you are proposing to solve the problem?
Since an invalid response typically requires server-side intervention,
I believe a 500 HTTP status code (Internal Server Error) would be more appropriate in this scenario.
What do you think?
If you agree, I can try submitting a PR with this change.
What alternatives have you considered?
N/A
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request