Stock levels are initialized and tracked accurately
Why it matters
A product schema without a stock field, or with a nullable stock that defaults to null, means the application has no authoritative source for inventory state. Every in-stock/out-of-stock display becomes a guess, overselling becomes possible on the first order, and inventory reports return NULL aggregates that silently break dashboards. ISO 25010:2011 functional-correctness requires correct outputs; a stock value of null produces neither "in stock" nor "out of stock" — it produces an error or a wrong assumption depending on how null is coerced in the display layer. Tracking stock is not optional for e-commerce.
Severity rationale
High because an absent or nullable stock field makes overselling possible on every order and renders all inventory reporting unreliable from the first data row.
Remediation
Add a stock field with a default of 0 in prisma/schema.prisma so newly created products start tracked rather than untracked.
model Product {
id String @id @default(cuid())
name String
stock Int @default(0)
}
In src/app/api/products/route.ts, always pass stock explicitly on creation rather than relying on the default — this prevents silent omissions in bulk import paths:
const product = await prisma.product.create({
data: { name, price, stock: initialStock ?? 0 },
})
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