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

Code that silently does the wrong thing

Map API field names at the boundary

When the public API names differ from the internal ones, a straight pass-through can validate cleanly and still drop the data; map the names explicitly at the boundary and test that the write took effect, not just that the call succeeded.

01 · Before and afterThe pattern

Translate at the API boundary, field by field, so a renamed field can't silently fall through.

TypeScript
// before: public shape handed to the service as-is; service ignores keys it doesn't know
await updateFields({ fields: input.fields });

// after: explicit mapping, so a missing name is a type error, not a silent no-op
await updateFields({
  fields: input.fields.map((f) => ({ id: f.id, pageNumber: f.page, pageX: f.positionX, pageY: f.positionY })),
});

02 · Run it on your appThe check

For each update endpoint, does a test read the record back and assert the new value, not just a 200 response?

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.