All products are assigned to at least one category
Why it matters
Products without a category assignment become invisible to browsing and filtering — they exist in the database but can't be discovered through any navigation path other than direct search. Beyond UX, ISO 25010:2011 functional-correctness treats uncategorized products as broken catalog behavior: the product is present but unreachable. A nullable categoryId foreign key means every product creation path in the codebase can skip assignment, and there's no audit trail for which products were left uncategorized. At scale, this creates catalog rot: orphaned products accumulate, promotional campaigns miss items, and inventory counts diverge from what customers see.
Severity rationale
High because uncategorized products disappear from browse and filter paths, making inventory effectively invisible to customers navigating the catalog — a silent revenue leak.
Remediation
Add a non-optional many-to-many relationship between Product and Category in prisma/schema.prisma, and enforce at least one category assignment in src/app/api/products/route.ts.
model Product {
id String @id @default(cuid())
name String
categories Category[]
}
model Category {
id String @id @default(cuid())
name String
products Product[]
}
In the product creation route, reject requests with an empty categories array:
if (!categoryIds || categoryIds.length === 0) {
return Response.json({ error: 'At least one category is required' }, { status: 400 })
}
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Catalog & Product Logic Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · functional-correctness — Functional Correctness (Functional Suitability)
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-catalog·automated