TLDR: Shopify stores order numbers as #472791. If your query strips the # from user input but matches with .eq(), you'll never find anything. Match both forms with .in().

the setup

We're building an internal supply chain OS for an ecommerce business.

One of the features a supply chain coordinator at the client needed was a warehouse error log: a place to capture it when the warehouse ships the wrong item, mislabels a box, or drops a bag on the floor.

Simple enough. Staff enters an order number, links it to the affected line item, logs what went wrong.

the wall

I built the feature, deployed it, tested it with CDP (Arc browser automation against prod)… and every single order lookup came back empty.

"No synced order found."

Every time. For every order number I typed.

what I assumed (and why it was wrong)

My first instinct was a sync issue — maybe the shopify_orders table didn't have recent data.

It did.

Then I assumed the user-input parsing was broken.

It wasn't.

The actual problem was embarrassingly simple: the query was stripping the # from user input (correct), then using .eq('order_number', cleaned) to match against the database… but Shopify stores order numbers WITH the leading #.

So I was querying '472791' against a column full of '#472791' values.

Exact match. Zero results. Every time.

the fix that worked

One line:

.in('order_number', [cleaned, `#${cleaned}`])

Match both forms. Done.

I also added a tiny display helper so the UI always renders exactly one #, regardless of what's stored:

function orderLabel(n: string | null): string {
  return `#${(n ?? '').replace(/^#/, '')}`
}

Strip, then re-add. Belt AND suspenders.

why this matters

Two systems will almost never agree on how to format the same identifier.

Shopify adds a #. Your user might not. Your old database might not either. None of them are wrong — they just never talked.

The lesson isn't "know Shopify's format" (you can look that up). The lesson is: whenever you're matching identifiers across a system boundary, canonicalize BOTH sides — or match all reasonable forms.

.eq() is an exact match. It's a sharp tool. It will silently return nothing when the format is off by one character and never tell you why.

Caught it with a single CDP smoke test on prod. Thirty seconds of browser automation, thirty minutes of not having this ship broken.

P.S. If you're building on Shopify's API and wondering why order_number is a string with a # prefix — welcome. You're not alone.