Skip to content
vetkitChecksChangelogDocumentation

vetkit.resilience.db-client-per-request.py-route

$CALL opens a new database connection or client inside the route handler $F, so every request pays for a TCP and TLS handshake and authentication, and concurrent requests can exhaust the database's connection limit.

Last updated:

Suite: Production readiness

python

$CALL opens a new database connection or client inside the route handler $F, so every request pays for a TCP and TLS handshake and authentication, and concurrent requests can exhaust the database's connection limit.

Category: RESILIENCE · Engine rule severity: WARNING

How to fix it

Create the engine, pool or client once at startup (module level, the app factory or a FastAPI lifespan handler) and reuse it; hand out per-request sessions or pooled connections from it, for example a SQLAlchemy sessionmaker, psycopg_pool.ConnectionPool or asyncpg.create_pool.

References

Source: packages/engine/rules/resilience/python.yml.

Generated from shipped rule definitions at build time. Matching is a review signal, not proof of exploitability. “generic” denotes text matching, not complete language or framework coverage. Runtime configuration and available tools affect whether a rule runs.