cloudflare / cloudflare/agentic-inbox
Standardize write-route input validation on safeParse + 400
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 964
- PR merge metrics
- No merged PRs in 30d
Description
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](workers/routes/cases.ts#L53) is the right one — `safeParse(await c.req.json().catch(() => null))` returning a 400 with a clean error.
### Sites to fix
- [workers/routes/reply-forward.ts:27](workers/routes/reply-forward.ts#L27)
- [workers/routes/reply-forward.ts:118](workers/routes/reply-forward.ts#L118)
- [workers/index.ts:112](workers/index.ts#L112) (`CreateMailboxBody`)
- [workers/index.ts:248](workers/index.ts#L248) (`SendEmailRequestSchema`)
- [workers/index.ts:294](workers/index.ts#L294) (`DraftBody`)
### 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.
Contributor guide
Assessment
This issue has not been assessed yet.