No `throw new Error("not implemented")` in production code
Why it matters
A throw new Error('not implemented') turns into an HTTP 500 the first time any caller hits that code path. Because AI generates these as scaffolding — calculateRefund, sendInvoice, getUserBalance — the thrown paths often sit directly on revenue-critical flows. Users encounter them during checkout, refund, or billing and abandon the transaction; the defect then masquerades as a generic 500 in observability and takes hours to trace back to the stub.
Severity rationale
Medium because the failure is loud but only triggers when the specific path executes, often on a less-travelled flow.
Remediation
Implement the function against real logic or remove it and adjust every caller. Do not leave scaffold throws behind; a // TODO next to a thrown error is still a 500 in production. Fix at src/lib/billing.ts:
export function calculateRefund(amount: number) {
const feePercent = 0.03
return amount * (1 - feePercent)
}
Detection
-
ID:
throw-not-implemented -
Severity:
medium -
What to look for: Walk all non-test source files. Count all
throwstatements whose error message matches this regex (case-insensitive):\b(not\s*implemented|not\s*yet\s*implemented|todo|implement\s*me|coming\s*soon|placeholder|stub|fixme|unimplemented|notimpl)\b. Also countthrow new NotImplementedError()regardless of message. Also countthrow 'not implemented'and similar string throws. EXCLUDE abstract class method bodies (files containingabstract class) AND interface stubs. -
Pass criteria: 0
throwstatements with "not implemented" messages in production code. Report: "Scanned X source files, 0 'not implemented' throws." -
Fail criteria: At least 1 source file contains a
throwwith a "not implemented" style message. -
Skip (N/A) when: Project has 0 source files.
-
Detail on fail:
"2 'not implemented' throws: throw new Error('Not yet implemented') in src/lib/billing.ts line 34 (function 'calculateRefund'), throw new Error('TODO: implement') in src/lib/email.ts line 12" -
Remediation: A
throw new Error("not implemented")means any code path that reaches this line will 500. AI often generates these as "scaffolding for later" — but the AI never comes back to replace them. Either implement the function or remove it and fix the caller:// Bad: function stub that throws export function calculateRefund(amount: number) { throw new Error('Not yet implemented') } // Good: implement it export function calculateRefund(amount: number) { const feePercent = 0.03 return amount * (1 - feePercent) }
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ai-slop-half-finished·automated