Each variant has a unique SKU or identifier
Why it matters
Duplicate SKUs break every system that uses SKU as a lookup key: warehouse management, shipping label generation, return processing, and analytics attribution. CWE-694 (Use of Multiple Resources with Duplicate Identifier) applies directly — two variants sharing SHIRT-RED-M means a barcode scan on the warehouse floor resolves ambiguously, order fulfillment picks the wrong record, and return lookups return both variants. Without a database-level UNIQUE constraint, application-level deduplication checks are vulnerable to race conditions under concurrent insertion — two simultaneous product imports can both pass validation and both write the same SKU.
Severity rationale
High because duplicate SKUs cause warehouse fulfillment ambiguity, incorrect return lookups, and broken order-to-variant joins that corrupt inventory counts.
Remediation
Add a @unique constraint to the sku field in prisma/schema.prisma so the database rejects duplicate SKUs at the storage layer.
model ProductVariant {
id String @id @default(cuid())
sku String @unique
productId String
product Product @relation(fields: [productId], references: [id])
size String
color String
}
In src/app/api/products/route.ts, catch the Prisma unique constraint error (P2002) and return a 409 with a clear message rather than letting it surface as a 500.
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
- cwe · CWE-694 — Use of Multiple Resources with Duplicate Identifier
- iso-25010:2011 · functional-correctness — Functional Correctness (Functional Suitability)
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-catalog·automated