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

task.mdevals/scenario-3/

Order Management API

Build an order management API with FastAPI and Python for a small e-commerce backend.

Endpoints

  • POST /api/orders -- create an order with customer_email: str, items: list where each item has product_name: str, quantity: int (> 0), unit_price: float (> 0)
  • GET /api/orders/{order_id} -- get order details including computed total
  • GET /api/orders -- list orders, with optional status: str filter and customer_email: str filter
  • PATCH /api/orders/{order_id}/status -- update order status with status: str (allowed transitions: "pending" -> "confirmed" -> "shipped" -> "delivered"; any state -> "cancelled" except "delivered")
  • POST /api/orders/{order_id}/notes -- add a note to an order with text: str, author: str
  • GET /api/orders/{order_id}/notes -- list notes for an order

Business rules:

  • An order must have at least one item
  • Status transitions must follow the allowed state machine
  • Cannot add notes to a cancelled order
  • Order total is computed from items (quantity * unit_price)

Output

Produce Python files:

  • app/main.py -- FastAPI app with routes
  • app/models.py -- Pydantic schemas for requests and responses
  • app/store.py -- in-memory data store (no real database)

Do not include test files or deployment configuration.

evals

tile.json