~/blog/orders-came-in-empty.mdx
The day after we shipped a cart, our orders came in empty
We shipped a cart on a Wednesday evening. A little over a day later, orders were landing in the database with a name, an address and an amount, but no products.
The fix was two lines. The interesting part is why the compiler let it through.
Some context first. Bandit Brothers is a small apparel brand I co-founded, and I built its online store. In January 2025 it grew from a WhatsApp order link into a store with online payments, and the cart came next.
Traffic was still small, and a few of us were placing orders to test the new checkout. Luckily, we caught the bug in that testing, before it reached customers.
What changed
Before the cart, the order page was one big form. The products a customer picked lived inside it, so the form values held everything an order needed. Building the order was a spread:
const order: Partial<Order> = {
...values,
paymentMode,
amount: orderTotal,
couponCode: coupon?.code ?? null,
createdAt: getTimestamp(),
}The cart moved products out of the form and into client-side cart state, so customers could add items from any page. The form schema dropped its products field. The total was still computed from the cart, so the amount looked right and checkout went through.
Nothing told me ...values no longer carried the products.
Why the compiler said nothing
Partial<Order> makes every field optional. I had used it because id and status don't exist yet when the browser builds an order: the server assigns them. That was the only reason. But Partial doesn't know that. It also made products, amount, email and everything else optional, so an order with no products was a perfectly valid Partial<Order>.
The type was describing "an order in progress". What I meant was "an order minus the two fields the server fills in".
The fix

The commit message was "fix: huuuuge order placement issue", which about covers how it felt.
With Omit, every other field is required again. Remove products: cart and the build fails with Property 'products' is missing. That's the error I wanted the day before.
What I do now
Partialis for patches. Update payloads, form drafts, test fixtures. Not for creating a record.- Name the fields you're leaving out.
Omit<T, 'id' | 'createdAt'>says exactly what the caller doesn't own, and keeps everything else required. - Be suspicious of a spread that builds a record.
...valueshides which fields it actually brings. When the source changes shape, the spread just brings less.
Postscript
We had zod from day one, but it was validating the checkout form. When products moved into the cart, they left the form's schema too, so the check had nothing to say about them. Today the server validates the order itself, and an order with no items is rejected before anything is saved.