ai-coding-minesIndexGitHub

One data shape carrying two meanings will be misread

Python and databases

Situation

A record's sources array had multiple entries — 1,107 records did.

While designing a new feature (bundled products), it was nearly read as "multiple entries, so this must be a bundle." It was in fact a list of alternative suppliers.

★★ Reading it that way would have sent wrong purchase orders for 1,107 items.

Fix — split fields by meaning, not by shape

{"is_set": true,
 "set_items": [...],   // bundle components
 "sources":   [...]}   // alternative suppliers

Both are arrays, but the names differ and different code consumes them. Bundle handling only triggers when the flag is set *and* the dedicated field exists.

Sharing the shape "many" does not make the meaning the same.

★★ Why add structure for a feature you aren't shipping — adding it later means reinterpreting 1,107 existing records, and that is exactly when the confusion happens. Draw the distinction while the count is small.