Invental/Review lessons/Code that silently does the wrong thing

Code that silently does the wrong thing

Audit stored values before reusing a field

Before giving a stored field a new meaning, list every value it already holds in production and who wrote it; a side-effect '' or a legacy false will be read by the new code as a deliberate choice.

01 · Before and afterThe pattern

TypeScript
// before: one flag and "string present" carry several meanings
const optedOut = !info.enabled;           // legacy rows have enabled:false and still show
const authored = typeof info.text === 'string'; // '' was written as a side effect

// after: explicit field for the new intent; empty legacy value = "not set"
const optedOut = info.notice_disabled === true;
const authored = Boolean(info.text);

02 · Run it on your appThe check

For the field you're about to reuse, have you queried what values existing rows hold and which old code path wrote each?

If the honest answer is no or not sure, this is worth a look before it reaches production.

Want this checked on your code?

Tell us what you are building and what worries you. We match a senior reviewer to your code and confirm scope before anything starts.

— Get in touch
hi@invental.co ↗
— Or
— What to include

A link or short description of the code or system, what you want checked, your stack, and when you need the answer. No repository access is needed until scope is agreed.

— Or leave a note
We reply within one business day.