How to fix: Generic Error Messages Leak No Context
The page responds with a generic catch-all error message (e.g., 'An error occurred', 'Something went wrong'). AI-generated code often wraps all exceptions in a single handler that swallows the real error, making debugging impossible and frustrating legitimate users.
Why it matters
While generic errors are good for security (they don't leak stack traces), they break the user experience and often indicate exception handling that silently discards important errors, including security-relevant ones.
AI-generated error handlers commonly produce single catch blocks with vague messages. The real risk is that the underlying exceptions, authentication failures, permission denials, data validation errors, are all treated identically, masking logic bugs and making incident response impossible.
How to fix it
- 1Log the full exception server-side with a correlation ID.
- 2Return structured errors with a code field: { error: 'VALIDATION_FAILED', code: 400, correlationId: 'abc123' }.
- 3Distinguish between user-facing messages (safe, vague) and internal logging (full detail).
- 4Never return the same message for a 400 validation error and a 500 database crash.
Code examples
Bad (AI-generated pattern)
try {
await doSomething();
} catch (err) {
// AI-generated: swallows all errors identically
return res.status(500).json({ message: 'An error occurred' });
}Better
try {
await doSomething();
} catch (err) {
const correlationId = crypto.randomUUID();
console.error('[doSomething]', { correlationId, err });
if (err instanceof ValidationError) {
return Response.json({ error: err.message, code: 'VALIDATION_FAILED' }, { status: 400 });
}
return Response.json({ error: 'Internal error', correlationId }, { status: 500 });
}References
Detected automatically by VulnRadar. The check id is vibe-generic-error-message, stable across every scan so you can filter or diff on it.
More ai code checks
- MediumTODO/FIXME Security Note in Response
- Higheval() Usage in Page Scripts
- HighSSL Certificate Verification Disabled
- HighMath.random() Used for Security Tokens
- CriticalHardcoded Credential in Authentication Logic
- CriticalJWT 'none' Algorithm Accepted
- CriticalSQL String Concatenation Pattern Detected
- MediumStack Trace Exposed in Response
Questions
- How severe is Generic Error Messages Leak No Context?
- VulnRadar rates this low severity in the ai code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id vibe-generic-error-message, which stays the same between runs so you can filter, diff, or gate CI on it.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.