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

Product Inventory API

Build a product inventory management API with FastAPI and Python. The API tracks products and stock adjustments.

Endpoints

  • POST /api/products -- create a product with name: str, sku: str, price: float (> 0), quantity: int (>= 0)
  • GET /api/products -- list all products, with optional query params min_price: float, max_price: float, in_stock: bool
  • GET /api/products/{product_id} -- get product by ID
  • PUT /api/products/{product_id} -- update product details
  • POST /api/products/{product_id}/adjust-stock -- adjust stock with adjustment: int (positive to add, negative to remove), reason: str
  • GET /api/products/{product_id}/stock-history -- get stock adjustment history for a product

Business rules:

  • SKU must be unique
  • Stock cannot go below zero after an adjustment
  • Price must be positive
  • Reason is required for stock adjustments

Output

Produce Python files:

  • app/main.py -- FastAPI app with routes
  • app/models.py -- Pydantic models
  • app/storage.py -- in-memory storage (no real database)

Do not include test files or deployment configuration.

evals

tile.json