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 a user registration and profile API with FastAPI",
"relevant_when": "Agent builds a FastAPI API with user management, CRUD operations, or form input handling",
"context": "Proactively check that agents apply FastAPI error handling best practices when building user-facing 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-exception-classes",
"rule": "Agent defines custom exception classes for domain errors (not-found, conflict, validation) rather than using bare HTTPException with string details",
"relevant_when": "Agent builds a FastAPI application with multiple error conditions"
},
{
"name": "exception-handler-for-custom-errors",
"rule": "Agent registers @app.exception_handler for custom exception types returning structured JSON with a code and message",
"relevant_when": "Agent builds a FastAPI application"
},
{
"name": "request-validation-error-handler",
"rule": "Agent registers @app.exception_handler(RequestValidationError) to produce structured per-field validation errors instead of FastAPI's default 422 format",
"relevant_when": "Agent builds a FastAPI application that validates request bodies"
},
{
"name": "catch-all-exception-handler",
"rule": "Agent registers @app.exception_handler(Exception) returning a safe generic message for unexpected errors without leaking tracebacks",
"relevant_when": "Agent builds a FastAPI application"
},
{
"name": "no-sensitive-data-in-errors",
"rule": "Error responses never echo back passwords, tokens, or other sensitive values",
"relevant_when": "Agent handles errors involving user credentials or sensitive fields"
},
{
"name": "appropriate-status-codes",
"rule": "Different error types use semantically correct HTTP status codes (404 for not found, 409 for conflicts, 400/422 for validation, 500 for unexpected)",
"relevant_when": "Agent returns error responses from FastAPI routes"
}
]
}