Will It Vibe logoWill It Vibe?
FASTAPI-018Low severity-4 points

Deprecated @app.on_event startup/shutdown hook

Part of Architecture & Best Practices, which counts for 15% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

@app.on_event('startup'/'shutdown') is deprecated in current FastAPI/Starlette in favor of the lifespan context-manager parameter passed to FastAPI(...), and is scheduled for removal in a future release.

Why it matters

@app.on_event('startup'/'shutdown') is deprecated in current FastAPI and Starlette in favor of the lifespan context-manager parameter, and is scheduled for removal in a future release. Code still relying on it will need to change eventually anyway, and in the meantime a reader has to know both the old and new patterns to understand a codebase that mixes them.

How to fix it

Replace @app.on_event handlers with a single async lifespan context manager passed to FastAPI(lifespan=lifespan): startup code goes before the yield, shutdown code goes after it. This also makes it easier to share state (like a database connection pool) between startup and shutdown without module-level globals.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Architecture & Best Practices checks