Commit 9bf4f6c
Fix stateless API test failures after OpenAPI migration
Two issues introduced by the OpenAPIHono conversion:
1. hasBody() returned false for test requests — Hono's app.request()
doesn't set Content-Length on string bodies, so the check for
Content-Length > 0 always failed in tests. Fix: fall back to
c.req.raw.body !== null (null = no body in tests; Node.js 24 real
HTTP bodyless POSTs always have Content-Length: 0 so they're caught
by the explicit check before the fallback).
2. Missing X-Sync-Params now returns Zod issues array — OpenAPIHono
validates the required x-sync-params header before calling the
handler, so requireSyncParams() was never reached. Fix: make the
header optional in the schema so requireSyncParams() handles
validation and returns the custom 'Missing X-Sync-Params header'
message.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude1 parent 887ac44 commit 9bf4f6c
1 file changed
Lines changed: 21 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | | - | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
65 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | | - | |
| 72 | + | |
68 | 73 | | |
69 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| |||
0 commit comments