CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/fastapi-error-handling

Production error handling for FastAPI — exception handlers, structured error

96

6.12x
Quality

96%

Does it follow best practices?

Impact

98%

6.12x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

criteria.jsonevals/scenario-1/

{
  "context": "Tests whether the agent proactively applies FastAPI error handling best practices when building a booking API. The task describes complex business rules that naturally produce many error cases but says nothing about exception handlers, error response formatting, or structured error responses -- the agent should add these on its own.",
  "type": "weighted_checklist",
  "checklist": [
    {
      "name": "Custom exception hierarchy",
      "description": "Agent defines custom exception classes (e.g. NotFoundError, ConflictError, BusinessRuleError) with at least a base class and specific subclasses, rather than using bare HTTPException everywhere. The agent was NOT asked to create exception classes.",
      "max_score": 12
    },
    {
      "name": "Exception handler for custom errors",
      "description": "Agent registers @app.exception_handler for custom exception types that produces a structured JSON error response with a code and message. The agent was NOT asked to register exception handlers.",
      "max_score": 14
    },
    {
      "name": "RequestValidationError handler",
      "description": "Agent registers @app.exception_handler(RequestValidationError) to reformat Pydantic validation errors with field-level detail in a structured format. The agent was NOT asked to customize validation errors.",
      "max_score": 14
    },
    {
      "name": "Generic Exception catch-all",
      "description": "Agent registers @app.exception_handler(Exception) returning a safe generic message for unexpected errors, without leaking tracebacks or internal paths. The agent was NOT asked about unexpected error handling.",
      "max_score": 14
    },
    {
      "name": "Consistent error response shape",
      "description": "All errors (validation, not-found, conflict, business rule violations) return the same JSON structure with a machine-readable code and human-readable message. No mix of different error formats.",
      "max_score": 12
    },
    {
      "name": "Correct HTTP status codes for business rules",
      "description": "Agent uses 409 for overlapping bookings and duplicate room names, 404 for room/booking not found, 400 or 422 for invalid times (end before start, past bookings), not all errors mapped to the same code.",
      "max_score": 10
    },
    {
      "name": "No stack traces in error responses",
      "description": "Error responses for internal server errors do not include Python tracebacks, file paths, or raw exception messages.",
      "max_score": 8
    },
    {
      "name": "Server-side error logging",
      "description": "The catch-all handler logs the actual exception server-side using logging, structlog, or similar. The agent was NOT asked to add logging.",
      "max_score": 8
    },
    {
      "name": "Validation details include field names",
      "description": "The RequestValidationError handler returns per-field error information (field name and description of what is wrong).",
      "max_score": 8
    }
  ]
}

evals

scenario-1

criteria.json

task.md

tile.json