Production error handling for FastAPI — exception handlers, structured error
96
96%
Does it follow best practices?
Impact
98%
6.12xAverage score across 5 eval scenarios
Passed
No known issues
{
"instruction": "Build an order management API with FastAPI",
"relevant_when": "Agent builds a FastAPI API with state machines, order processing, or complex business rules",
"context": "Proactively check that agents apply FastAPI error handling best practices when building order/workflow APIs, even when not explicitly asked to add error handling.",
"sources": [
{
"type": "file",
"filename": "skills/fastapi-error-handling/SKILL.md",
"tile": "tessl-labs/fastapi-error-handling"
}
],
"checklist": [
{
"name": "custom-exceptions",
"rule": "Agent defines custom exception classes for domain errors (NotFoundError, InvalidStateTransition, etc.) rather than using bare HTTPException everywhere",
"relevant_when": "Agent builds a FastAPI application with business logic errors"
},
{
"name": "exception-handler-registered",
"rule": "Agent registers @app.exception_handler for custom exception types returning structured JSON with code and message",
"relevant_when": "Agent builds a FastAPI application"
},
{
"name": "validation-error-handler",
"rule": "Agent registers @app.exception_handler(RequestValidationError) with per-field error details in a consistent format",
"relevant_when": "Agent builds a FastAPI app accepting request bodies"
},
{
"name": "generic-catch-all",
"rule": "Agent registers @app.exception_handler(Exception) returning a safe generic error message without leaking internal details",
"relevant_when": "Agent builds a FastAPI application"
},
{
"name": "consistent-error-shape",
"rule": "All error responses (validation, not-found, business rule violations, state transition errors) use the same JSON structure with a code and message",
"relevant_when": "Agent returns error responses from FastAPI routes"
},
{
"name": "correct-status-codes",
"rule": "Different error types use semantically correct HTTP status codes (404, 409, 400/422, 500) not all mapped to the same code",
"relevant_when": "Agent returns error responses from FastAPI"
}
]
}