All Concept Bites
35 views
Software Engineeringintermediate

Green Tests, Wrong Code: The Migration Trap

A migration changes a contract your typical tests never touch — so passing proves little.

Reviewed by Abhijith N M · 24 October 2026 · Editorial standards

The Simple VersionNo jargon

Say a function used to throw an error on bad input and now returns null instead. Your test calls it with a normal input like "42", checks the result, and passes. The code runs cleanly. The result is wrong. Nothing in the test suite noticed, because the test only ever exercised the easy path. A preregistered study (the design is fixed and registered before running) looked at 73 repair tasks covering 60 documented changes in CPython, Node.js and SQLite. Each candidate repair ran on the real runtime and was checked against contracts the repairer never saw. Gating on all the typical-input assertions still let 0.410 of wrong repairs through. Adding one edge input written from the release note dropped that to 0.065. Three inputs from a blind frontier-model writer that never saw the program reached 0.070; two local-model writers failed their preregistered tests. The mechanism is simple. A migration changes a contract: a return type, what an error means, the order of results. Typical inputs don't reach the changed part. So a green suite certifies that the easy path still works, not that the contract holds. Release notes are where the contract change is written down. "Now returns null instead of throwing" is a test you can write. One adversarial input per documented change is cheap and it targets exactly the gap. The limits matter. On the hard-distractor set — 233 distractors built to match the legacy output on typical inputs — the edge input still let 0.168 of wrong programs pass (0.153 for the frontier-model writer). An AI reviewer that could not see the intended answers flagged 34 contracts as stricter than their requirements; dropping those checks changed 0 verdicts, though the class-label disputes remain open. One input is a big improvement, not a guarantee. This is an arXiv preprint, and artifacts are available from the authors on request.

Green Tests, Wrong Code: The Migration Trap — Visual Breakdown

Click any step below to inspect
Migration changes a contract
Typical-input tests still pass
Release gate goes green
Add one edge input from release note
Wrong repair caught
Sequence of Events
Why It Matters in Production
Most teams treat a green suite as permission to ship. This study shows the gate, not the model, is the weak point: on typical inputs it released 0.410 of wrong repairs. Anyone running automated LLM repairs after an API migration is exposed, because the failure is silent — the code runs and returns plausible wrong values. The same failure mode plausibly applies to dependency upgrades, though the study only tested LLM repairs. The fix is cheap: read the release note, write one input that exercises the changed contract. That dropped wrong releases to 0.065, but on the hard-distractor set the edge input still let 0.168 of wrong programs pass (0.153 for the frontier-model writer), so one edge case raises the floor rather than closing the gap.
Implementation & Syntax
🟨JavaScript
const assert = require('node:assert');

// Before the migration: parseCount threw on bad input.
// After: it returns null. Typical tests never pass bad input.

function parseCount(s) {
  const n = Number(s);
  return Number.isFinite(n) ? n : null; // was: throw new Error(...)
}

// Typical input — passes under both the old throw-on-bad-input
// and new return-null behaviour, so it cannot tell them apart.
assert.equal(parseCount("42"), 42);

// Edge input derived from the release note: error semantics changed.
assert.equal(parseCount("abc"), null); // fails on the old throw-based repair

Quick Concept Check

Test your understanding in 15 seconds

Why does an all-assertions gate on typical test inputs release wrong repairs after an API migration?

Bite Progression22 / 36

Related Concepts

Complementary topics

Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.