TLDR: I assumed I knew the shape of a TakeShape API response. I was wrong. 856 of 859 cancer treatment centers silently lost their addresses. Fixed in one commit — but the lesson still stings.

The Project

A cancer treatment center finder connects cancer patients to treatment centers across the US and Mexico — everything from integrative clinics in Mesa, AZ to specialty centers in Tijuana.

Facility data lives in TakeShape (a headless CMS/GraphQL API platform), and we pull it down into our own Postgres database via an import script.

Or supposed to, anyway.

The Bug

Somewhere in the import, I typed the physicalLocations field wrong.

My TypeScript type said the API returned an array of objects: [{ location: {...} }].

The API actually returns an object with an array field: { location: [{...}] }.

One bracket. One wrong assumption. And TypeScript didn't yell — the data flowed in, my buildLocation function hit .length on undefined, silently fell through to the fallback… and returned "Unknown".

For 856 out of 859 facilities.

What the AI Was Doing

Here's the part that makes me cringe.

Every time a cancer patient asked the chatbot to recommend a center, the AI was dutifully responding with things like "an integrative clinic — location unknown" and "a national cancer treatment network — location unknown."

For elderly patients trying to find care. Trust-signal collapse doesn't begin to cover it.

The system didn't throw an error. It didn't raise a flag. It just quietly served "Unknown" to every single lead.

The Fix

Once I traced it, the fix was fast:

  • Rename TsPhysicalLocationTsPhysicalLocations to match the real API shape
  • Update buildLocation to unwrap physicalLocations.location correctly
  • Write scripts/backfill-locations.ts — a targeted script that only rewrites the location column per takeshape_id, leaving everything else untouched

Backfill results:

  • 849 facilities now show real addresses (Mesa, AZ; Tampa, FL; Tijuana, MX; etc.)
  • 7 still "Unknown" — legitimately missing from TakeShape
  • Before: 3 real, 856 Unknown

Why This Matters to Me

My schema was a hypothesis dressed up as a fact.

I assumed the API shape. I didn't verify it against a real response. I wrote a type, the type compiled, and I shipped it — treating my own mental model as ground truth.

The thing is, your code doesn't care what you assumed. The data doesn't read your comments. If the fallback is graceful ("Unknown" beats a crash), the system will happily lie for you — at scale, in production, to vulnerable people — until you look.

Always verify the actual API shape before you type it. Run a real query. console.log the raw response. Don't let a clean compile tell you everything's fine.

P.S. If you're working with any GraphQL CMS — TakeShape, Contentful, Sanity — paste the actual response into a schema validator before writing your TypeScript types. Takes 30 seconds and it would have saved me an embarrassing backfill.