Search docs
Docs searchValidation rule
Back to Rule CatalogAP-TEN-002Tenant IsolationMissing tenant enforcement on data access
Flags data access without clear tenant-scoping enforcement.
warningviolationNo auto-fix
How to fix
- Add tenant constraints to the query.
- Require tenant scope in repository inputs.
- Review raw SQL and ORM calls for tenant filters.
What it means
A query or mutation touches tenant-owned data without obvious tenant constraints.
Why it matters
Tenant enforcement at data access prevents cross-tenant reads and writes even when higher layers make mistakes.
Common causes
- A where clause omits organizationId.
- A repository method accepts an id but not tenant scope.
- Raw SQL is not constrained by tenant columns.
Example bad pattern
findUnique({ where: { id: repositoryId } }) for an organization-scoped repository.Example good pattern
findFirst({ where: { id: repositoryId, organizationId } }).Related files/config
apps/api/srcapps/web/app/apipackages/db/prisma/schema.prisma
Related CLI commands
archpilot validatearchpilot validate --ci
Related docs