Ledger Fox
Original demonstration · synthetic data · JavaScript only

Zero must stay zero.

One small transformation bug can turn an out-of-stock quantity into a missing value. Here is the failing example, a precise correction, and the files to reproduce it.

This is not an executed n8n workflow. The proof runs as plain JavaScript over synthetic item envelopes. It is not a client case study, a live API test, or evidence that your production integration works.

The failure

parseInt(value, 10) || null

Zero becomes null. A value such as "12pcs" silently becomes 12, and "1.5" becomes 1.

The correction

Validate the entire quantity, then accept only a nonnegative safe integer. Preserve zero and route ambiguous values for review.

Every input row remains visible. Nothing is sent to a store or external service.

Seven input rows, one explicit expected result

These are the bundled fixture results. The replay command verifies the corrected output against expected.json.

Synthetic inputOriginal stock / statusCorrected stock / status
"0"null / review0 / ready
"12"12 / ready12 / ready
""null / reviewnull / review
"12pcs"12 / readynull / review
"1.5"1 / readynull / review
"-1"-1 / readynull / review
4, blank SKU4 / review4 / review

Inspect and reproduce

Save the files below together in one folder. With Node.js 22 or newer, run:

node --test transform.test.mjs
node demonstrate.mjs

Six tests check the original bug, the complete expected output, integer bounds, invalid shapes, non-mutation and repeatable replay. The example needs no packages, accounts, credentials or external calls.

Your expected behavior defines the repair.

This example assumes whole, nonnegative inventory quantities. Some businesses need fractions or negative inventory; those rules must be agreed before a patch. This sample does not merge duplicate SKUs or perform an import.

Describe one failing path through the existing private intake