Why this matters
Accurate status codes make client behavior predictable and improve monitoring.
Handlers must return non-2xx status codes for error outcomes and include a minimal error body that does not leak sensitive details.
Accurate status codes make client behavior predictable and improve monitoring.
Side-by-side examples engineers can pattern-match during review.
res.status(200).json({ error: 'failed' });try{ const x = await create(); res.status(201).json(x); }catch(e){ logger.error('create failed',{e}); res.status(500).json({error:'internal_error'}); }res.status(200).json({ error: 'x' })res.status(500).json({ error: 'internal_error' })From the same buckets as this rule.