An invalid object state is data that violates a domain invariant: a rule that must remain true for the system to represent a valid business reality. The data may exist in a database while making no sense outside it. section 13.1.2
Investigate invalid states by asking which business rule failed and how the data became inconsistent:
- Check for race conditions, delayed or out-of-order messages, retries, and eventual-consistency gaps. section 13.1.2
- Look for missing defensive checks and partially completed operations across services or databases. section 13.1.2
- Validate domain rules directly; logs and traces can miss inconsistencies that invariant checks expose. section 13.1.2
Concrete invalid states
A payment completes without an order, a user has a birthdate in the future, or a refund is processed before its referenced order is written. Each condition can technically exist while violating business reality. section 13.1.2
SELECT * FROM refunds r WHERE NOT EXISTS ( SELECT 1 FROM orders o WHERE o.id = r.order_id );
Find refunds whose referenced orders do not exist, exposing one class of invalid state directly in stored data. section 13.1.2
