- Home
- Skills
- APIs & Backend
- repair api error mapping status bugs
More screenshots
Works with the AI tools you already use
repair api error mapping status bugs
Diagnose and repair HTTP/gRPC status code mappings, error redaction, and retry logic.
$8.99
repair api error mapping status bugs
Example session with this skill installed
Fix the error handling in our Express user controller. It currently returns a 500 when a username is taken, and I'm worried it might be leaking the raw MongoDB error object to the frontend.
- Read your context and instructions
- Compiled the repair api error
I analyzed controllers/userController.js and confirmed the catch block passes the raw MongoServerError to the client. This results in a 500 status and exposes internal collection names. I have remapped this to a 409 Conflict and added a redaction layer.
API Error Mapping Repair
| Internal Failure | Protocol Status | Public Code | Retryable | Changes Made |
|---|---|---|---|---|
| MongoServerError (11000) | 409 Conflict | USER_ALREADY_EXISTS | No | Mapped specific code to 409, sanitized body. |
| ValidationError | 400 Bad Request | INVALID_INPUT | No | Extracted error messages into safe list. |
| Generic / Unknown | 500 Internal Server Error | INTERNAL_ERROR | No | Replaced raw message with opaque trace ID. |
// controllers/userController.js - Refactored catch block
try {
const user = await User.create(req.body);
res.status(201).json(user);
} catch (err) {
const correlationId = logger.error(err); // Log full error internally
if (err.name === 'MongoServerError' && err.code === 11000) {
return res.status(409).json({
code: 'USER_ALREADY_EXISTS',
message: 'The requested username is unavailable.',
correlationId
});
}
if (err.name === 'ValidationError') {
return res.status(400).json({
code: 'INVALID_INPUT',
message: 'Validation failed.',
details: Object.values(err.errors).map(e => e.message),
correlationId
});
}
// Final fallback to prevent information leakage
res.status(500).json({
code: 'INTERNAL_ERROR',
message: 'An unexpected error occurred.',
correlationId
});
}
Next steps
- Run the new integration tests in
tests/userErrors.test.jsto verify the 409 and 400 paths. - Check your frontend error handling to ensure it correctly parses the new
USER_ALREADY_EXISTScode. - Review the logs to confirm the
correlationIdis correctly linking public errors to internal stack traces.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
The problem
APIs often leak sensitive internal stack traces, return generic 500 errors for client-side validation failures, or incorrectly mark terminal errors as retryable. These mapping defects break client resilience logic and create security vulnerabilities.
What it does
- Identifies incorrect HTTP/gRPC status code mappings from internal domain failures.
- Audits error envelopes to ensure sensitive data and secrets are redacted before reaching the public boundary.
- Distinguishes between retryable transient failures and terminal logic errors to prevent infinite loop bugs.
- Generates deterministic test cases to verify error classification and correlation ID propagation.
- Standardizes error taxonomies across validation, auth, conflict, and timeout scenarios.
Frameworks & tools
Works with any API framework using HTTP or gRPC protocols. Supports testing via deterministic mocks and fixtures.
Why this beats prompting it yourself
Writing error handlers is tedious and prone to edge-case leaks. This skill enforces a strict contract reconstruction process, ensuring you don't accidentally weaken auth checks or expose raw dependency errors while trying to fix a status code.
Use cases
- Fixing a Node.js API that returns 500 Internal Server Error for duplicate key conflicts.
- Implementing gRPC status code standards for a Go microservice.
- Redacting database connection strings from production error responses.
- Correcting client retry logic by properly flagging idempotent versus non-idempotent failures.
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 21 days ago
- Passed all security checks, Safe to install