Validate FastAPI Project
When to Use
Use this skill when auditing a FastAPI project for quality, performance, or security issues.
Instructions
Check for Pydantic v1 patterns:
.dict(),.json(),.parse_obj(),.parse_raw(),.__fields__@validator,@root_validatorclass Config:withorm_modeconint,constr,confloatconstrained typesfrom pydantic import BaseSettings(moved topydantic-settings)
Check for async anti-patterns:
requests.*inasync defendpointstime.sleep()inasync defendpointsopen()file I/O inasync defendpoints- Sync database drivers (psycopg2, PyMySQL) with async engine
- Missing
awaiton async calls - CPU-heavy code without
run_in_executor
Check for missing response models:
- Endpoints without
response_modelparameter - Response models that expose sensitive fields (password, hashed_password, secret_key)
- Endpoints without
Check for database issues:
- Sessions not using dependency injection (manual creation without cleanup)
- Missing
expire_on_commit=Falseon async sessions - Lazy loading without eager load options (causes N+1 or MissingGreenlet)
- Missing
pool_pre_ping=Trueon engine
Check for security issues:
- Hardcoded secrets
- Missing authentication on protected endpoints
- CORS with
allow_origins=["*"]in production Exceptioncaught and details exposed to client- File uploads without size/type validation
- Missing rate limiting on public endpoints
Check for deprecated patterns:
@app.on_event("startup"/"shutdown")(use lifespan)- Inline
Depends()instead ofAnnotated
Produce a summary report with issue count, severity, file locations, and fixes.
Source: RoninForge/roninforge-fastapi — distributed by TomeVault.