Handle malformed auth recovery request bodies#193
Conversation
Greptile SummaryThis PR replaces raw
Confidence Score: 5/5Safe to merge — the changes are narrow, well-tested, and harden error handling without altering any successful-path logic. Each route now returns a deterministic 400 for malformed input instead of falling into the catch-all 500 handler. The webhook secret check in the confirmed route is unchanged and still runs before body parsing. Regression tests cover all four routes and assert that downstream side effects do not fire on bad input. No files require special attention. src/lib/sanitize.ts (not changed here) silently accepts JSON arrays; this does not affect the routes in this PR but would be worth addressing if safeParseBody is reused in contexts that must distinguish arrays from objects. Important Files Changed
Reviews (1): Last reviewed commit: "Handle malformed auth recovery bodies" | Re-trigger Greptile |
Summary
safeParseBodyin forgot-password, reset-password, resend-confirmation, and auth-confirmed routes so malformed/empty/non-object JSON returns 400 instead of falling into 500 handlers.Fixes #192
Verification
./node_modules/.bin/vitest run src/app/api/auth/forgot-password/route.test.ts src/app/api/auth/reset-password/route.test.ts src/app/api/auth/resend-confirmation/route.test.ts src/app/api/auth/confirmed/route.test.ts./node_modules/.bin/eslint src/app/api/auth/forgot-password/route.ts src/app/api/auth/reset-password/route.ts src/app/api/auth/resend-confirmation/route.ts src/app/api/auth/confirmed/route.ts src/app/api/auth/forgot-password/route.test.ts src/app/api/auth/reset-password/route.test.ts src/app/api/auth/resend-confirmation/route.test.ts src/app/api/auth/confirmed/route.test.ts./node_modules/.bin/tsc --noEmit --pretty falsegit diff --check -- src/app/api/auth/forgot-password/route.ts src/app/api/auth/reset-password/route.ts src/app/api/auth/resend-confirmation/route.ts src/app/api/auth/confirmed/route.ts src/app/api/auth/forgot-password/route.test.ts src/app/api/auth/reset-password/route.test.ts src/app/api/auth/resend-confirmation/route.test.ts src/app/api/auth/confirmed/route.test.ts