We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@hono/arktype-validator
2.0.0
4.7.2
bun 1.2.0
repro repository: https://github.com/FLchs/bun-hono-arktype
import { Hono } from 'hono' import { type } from 'arktype' import { arktypeValidator } from '@hono/arktype-validator' import { z } from 'zod' import { zValidator } from '@hono/zod-validator' const schema = type({ name: 'string', age: 'number' }) const schemaZ = z.object({ name: z.string(), age: z.number() }) const app = new Hono() app.post('/ark', arktypeValidator('json', schema), (c) => { const data = c.req.valid('json') return c.json({ success: true, message: `${data.name} is ${data.age}`, }) }) app.post( '/zod', zValidator('json', schemaZ), (c) => { const data = c.req.valid('json') return c.json({ success: true, message: `${data.name} is ${data.age}`, }) }) export default app
Now call both enpoint with invalid body (age should be a number):
{ "name": "francois", "age¨: "35" }
Both endpoint should error in the same way : sending a 400
Zod endpoint fail successfully (!) by sending:
{ "success": false, "error": { "issues": [ { "code": "invalid_type", "expected": "number", "received": "string", "path": [ "age" ], "message": "Expected number, received string" } ], "name": "ZodError" } }
ArkType endpoint will crash the server: Internal Server Error logs:
Internal Server Error
221 | return this.#newResponse(text, arg, headers); 222 | } 223 | return this.#newResponse(text, arg); 224 | }; 225 | json = (object, arg, headers) => { 226 | const body = JSON.stringify(object); ^ TypeError: JSON.stringify cannot serialize cyclic structures. at json (/home/francois/Projects/Personal/bun-hono-arktype/node_modules/hono/dist/context.js:226:23) at <anonymous> (/home/francois/Projects/Personal/bun-hono-arktype/node_modules/hono/dist/validator/validator.js:76:23)
Using the hook works:
arktypeValidator('json', schema, (result, c) => { if (!result.success) { return c.text('Invalid!', 400) } })
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Which middleware has the bug?
@hono/arktype-validator
What version of the middleware?
2.0.0
What version of Hono are you using?
4.7.2
What runtime/platform is your app running on? (with version if possible)
bun 1.2.0
What steps can reproduce the bug?
repro repository: https://github.com/FLchs/bun-hono-arktype
Now call both enpoint with invalid body (age should be a number):
What is the expected behavior?
Both endpoint should error in the same way : sending a 400
What do you see instead?
Zod endpoint fail successfully (!) by sending:
ArkType endpoint will crash the server:
Internal Server Error
logs:
Additional information
Using the hook works:
The text was updated successfully, but these errors were encountered: