RESEARCH TO PRODUCTION

One Closure Bug, Three Languages, 183 Customers Gone

One closure bug dropped 183 of 184 customers. We hand-tested it in JavaScript and Ruby: var and for share one binding across the loop, so every helper reads the last row and all three scripts exit 0 with one row. The fixes keep all 184.

2026-11-24

One closure bug dropped 183 of 184 customers. An AI-written Python script stored a helper per row that read the loop variable after the loop ended, so every helper read the last row and deduplication collapsed all 200 rows to one. We hand-tested the same bug in JavaScript and Ruby, and both collapsed the same way.

The 41-second reel: one closure bug, three languages, 183 customers gone.

The bug, in three languages

Python was the original failure. In Part 1, an Opus 5.5 script saved a helper function per row that referenced the loop variable, and late binding meant every helper read the last row once the loop finished. The script exited 0 and wrote one row: the last customer, Mateo Rossi.

We hand-tested the same shape in JavaScript and Ruby. JavaScript with var shares one binding across the whole loop, so every helper reads the last row. Ruby with for does the same: the loop variable is one shared binding, not a fresh one per pass. Both scripts collapsed 200 rows for 184 customers to one row, and both exited zero.

The fixes

Each language has a one-word fix that gives every row its own binding. JavaScript’s let inside the loop body is fresh on every pass. Ruby’s each binds a fresh block parameter on every yield, leaving no shared loop variable at all. Python’s default argument binds the row when the helper is defined. All three fixed versions kept all 184 customers, and every one matched the expected output file, all six columns across all 184 rows.

The check

Assert that output row counts match distinct input keys and check newest dates, because exit zero misses dropped rows. The distinct count has to come from the input file, not from the deduped output: comparing a dedupe against itself passes even when it kept stale rows. Dedupe on the newest date, not the first row you see. First-occurrence dedupe on this file would have kept 3 stale rows.

The reproduction

This is our own Nov 23, 2026 reproduction at Part 1’s scale, not the original file: 202 lines with 1 top header, 1 repeated mid-file header, and 200 data rows covering 184 unique customers and 16 duplicates, including 6 near-duplicates with older dates, 3 of them sitting before their newer row, plus quoted names and mixed money and date formats.

Caveats

The Python failure is from Part 1’s test run on Nov 16, 2026 (one Opus 5.5 run out of three; its other two runs passed 184 of 184). The JavaScript and Ruby tests were hand-written by us to reproduce the same failure shape, not generated by a model. This is a failure mode we reproduced, not a model ranking and not a language ranking.

Sources

This post started as an Instagram post →

Discussion

Talk it through

Argue with us on Instagram.