Search docs
Docs searchValidation rule
Back to Rule CatalogAP-DQR-001Data / Query RiskMissing tenant filter evidence in multi-tenant SQL
Flags query paths where multi-tenant SQL lacks clear tenant-filter evidence.
warningviolationNo auto-fix
How to fix
- Add an explicit tenant filter to the query.
- Pass tenant context through repository/service boundaries.
- Document intentional shared queries and add tests that prove tenant isolation.
What the rule validates
A query appears to touch tenant-scoped data without an obvious tenant filter.
Why it matters
Missing tenant filters can expose or mix data across tenants.
Common causes
- Raw SQL omits tenant_id.
- Tenant scoping is hidden behind an abstraction ArchPilot cannot identify.
- A test fixture or report query was copied into production code.
Typical violation example
SELECT * FROM invoices WHERE status = 'open'Typical compliant example
SELECT id, status FROM invoices WHERE tenant_id = $1 AND status = 'open'Related rules
AP-DQR-002 - Broad SELECT * usage in query pathAP-DQR-003 - Unbounded query risk without limit/pagination evidenceAP-DQR-004 - Cross-module direct database access bypasses module boundaryAP-DQR-005 - N+1 query evidence in collection loop
Adjacent categories
Related files/config
apps/api/srcdb/sqlpackages/db/prisma/schema.prisma
Related CLI commands
archpilot validatearchpilot validate --ci