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-4/

Payment Processing API

Build a payment processing API with FastAPI and Python. The API manages customers and their payments.

Endpoints

  • POST /api/customers -- create a customer with name: str, email: str, balance: float
  • GET /api/customers/{customer_id} -- get customer by ID
  • POST /api/payments -- process a payment with customer_id: int, amount: float, currency: str (must be "USD", "EUR", or "GBP")
  • GET /api/payments/{payment_id} -- get payment by ID
  • POST /api/payments/{payment_id}/refund -- refund a payment (only if status is "completed")

Business rules:

  • A payment fails if the customer's balance is less than the amount
  • A payment can only be refunded once
  • Customer email must be unique

Output

Produce Python files:

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

Do not include test files or deployment configuration.

evals

tile.json