Standardize write-route input validation on safeParse + 400

Author: schmugCreated Apr 27, 2026Updated May 14, 2026

Several write routes call Schema.parse(await c.req.json()), which throws on malformed JSON and surfaces as a 500. The pattern in workers/routes/cases.ts:53 is the right one — safeParse(await c.req.json().catch(() => null)) returning a 400 with a clean error.

Sites to fix

Why

Consistent 400s instead of 500s on malformed client input; reduces noise in error monitoring; matches the pattern already used in cases.ts.

Effort

~5 mechanical replacements, single small PR.

Source: cloudflare/agentic-inbox