[Data integrity] No DB-level CHECK constraint for userId XOR guestToken invariant #23
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Identified during advisory review of #17 (guest checkout).
Problem
The
OrderJavadoc states "Either userId or guestToken is set; never both, never neither", but only theonCreate()lifecycle callback enforces this invariant in Java. A stray INSERT (admin tooling, future script, manual SQL) could violate it silently - for example creating an order with neither set, or both set, which would put it outside both the JWT and guest lookup paths.Severity
Warning (silent data corruption)
Suggested fix
Add a CHECK constraint in a follow-up Flyway migration (V13):
References