All 35 Bugs /
0/35 Fixed ✓
Node/ExpressHard~15 min

Missing Input Validation & Async Error Leak

What's Broken (Symptom)

Negative `amount` / blank `email` reaches the DB layer, and when `saveOrder` rejects, the controller hangs or crashes instead of forwarding to `next(err)`.

Expected Behavior

  • Validate `email` (must contain `@`) and positive finite `amount > 0`, returning `400` JSON immediately when invalid.
  • Wrap async `await saveOrder(...)` in `try / catch` and pass unexpected failures to `next(err)`.
  • Return `201` JSON on valid input without touching `next(err)`.

Debugging Hints (0/2 used)

Try spotting the bug in the editor first. Need a nudge? Reveal Hint 1 anytime.

Root Cause Breakdown

Pass all 3 automated verification checks on the right to unlock the full Root Cause explanation.

Automated Bug Verification

3 Checks Ready
  • Rejects bad email and negative amount with 400 before DB callsaveOrder must not run on invalid payload.
  • Catches rejected DB promise and passes error to next(err)Error must be routed to Express error handler.
  • Normalizes email & returns 201 for valid payloadHappy path persists and returns 201.
bugfix.js
Live Sandboxed PreviewCtrl + Enter to verify
Console Output0 log(s)
No console output yet. Run Preview or Verify Bug Fix.