- Home
- Skills
- APIs & Backend
- repair api error mapping status bugs
More screenshots
Works with the AI Agents you already use
repair api error mapping status bugs
Diagnose and repair HTTP/gRPC status code mappings, error redaction, and retry logic.
$1
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.
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.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Does not modify authorization or security policies unless explicitly requested. Requires clear visibility into internal error sources for full repository mode.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 months ago