Commit 41a0063
committed
admin: oversized create-table body returns 413, not 400 (Codex P2)
decodeCreateTableRequest used to surface every read/parse failure
as the same generic "invalid_body" string, so handleCreate mapped
all of them to 400 — including the BodyLimit/MaxBytesReader
overflow that should produce 413 payload_too_large.
The middleware contract in internal/admin/middleware.go promises
413 on oversized bodies (WriteMaxBytesError lives in that file
exactly for this purpose). Codex P2 on PR #634 flagged the
write path as the only handler that broke that contract: callers
and retry logic could not distinguish "body too big" from "body
malformed", and oversize requests would be retried as if a
caller-side fix was possible.
Fix: introduce errCreateBodyTooLarge as a sentinel returned only
when io.ReadAll trips MaxBytesReader. handleCreate matches the
sentinel via errors.Is and routes to WriteMaxBytesError, which
emits the canonical 413 + payload_too_large body. All other
decode paths still produce 400 invalid_body unchanged.
Test: TestDynamoHandler_CreateTable_OversizedBodyReturns413
wraps the request body in MaxBytesReader (mirroring what the
real BodyLimit middleware does) and confirms the response is
413 with a payload_too_large code. Also asserts the stub source
is not touched on rejection.1 parent dcac6e4 commit 41a0063
2 files changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
136 | 145 | | |
137 | 146 | | |
138 | 147 | | |
| |||
280 | 289 | | |
281 | 290 | | |
282 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
283 | 296 | | |
284 | 297 | | |
285 | 298 | | |
| |||
362 | 375 | | |
363 | 376 | | |
364 | 377 | | |
365 | | - | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
366 | 381 | | |
367 | 382 | | |
368 | 383 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
490 | 518 | | |
491 | 519 | | |
492 | 520 | | |
| |||
0 commit comments