FAILURE MAP
← Case archive

FA-47351 / Delimited text / Open access

Canonical duplicate columns overwrite each other · case 01

A structured table violates the declared record or column contract.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Dictionary construction erases duplicate column identity.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if len(set(headers)) != len(headers): return None

Unsuccessful approach: Guarding only wide tables still loses a two-column duplicate.

Case contract

Bind a comma-split header and data row. Header keys are ASCII case insensitive and stripped. Reject empty or duplicate canonical names, reserved _extra, and unequal width. Preserve data cell whitespace.

Why this case matters

Delimited interchange needs explicit framing, schema and field semantics at ingestion and emission boundaries.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    headers = [h.strip().lower() for h in data[0].split(',')]
    values = data[1].split(',')
    if any(not h for h in headers): return None
    if False: return None
    if '_extra' in headers: return None
    if len(values) != len(headers): return None
    return dict(zip(headers, values))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('canonical names', solve(_vary([' A ,B', '@, y '])), _vary({'a': '@', 'b': ' y '}))
check('duplicate canonical', solve(_vary(['A,a', 'x,y'])), _vary(None))
check('empty header', solve(_vary(['a,', 'x,y'])), _vary(None))
check('reserved header', solve(_vary(['_extra,b', 'x,y'])), _vary(None))
check('short row', solve(_vary(['a,b', '@'])), _vary(None))
check('long row', solve(_vary(['a', 'x,y'])), _vary(None))
check('normal', solve(_vary(['a,b', 'x,y'])), _vary({'a': 'x', 'b': 'y'}))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
canonical names{'a': 'cell', 'b': ' y '}{'a': 'cell', 'b': ' y '}Passed
duplicate canonical{'a': 'y'}NoneFailed
empty headerNoneNonePassed
reserved headerNoneNonePassed
short rowNoneNonePassed
long rowNoneNonePassed
normal{'a': 'x', 'b': 'y'}{'a': 'x', 'b': 'y'}Passed

SHA-256 / bb225b285ee5241d3b7415b95b52badacd7be33c5a14364a12725e175e648ba2

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    headers = [h.strip().lower() for h in data[0].split(',')]
    values = data[1].split(',')
    if any(not h for h in headers): return None
    if len(headers) > 2 and len(set(headers)) != len(headers): return None
    if '_extra' in headers: return None
    if len(values) != len(headers): return None
    return dict(zip(headers, values))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('canonical names', solve(_vary([' A ,B', '@, y '])), _vary({'a': '@', 'b': ' y '}))
check('duplicate canonical', solve(_vary(['A,a', 'x,y'])), _vary(None))
check('empty header', solve(_vary(['a,', 'x,y'])), _vary(None))
check('reserved header', solve(_vary(['_extra,b', 'x,y'])), _vary(None))
check('short row', solve(_vary(['a,b', '@'])), _vary(None))
check('long row', solve(_vary(['a', 'x,y'])), _vary(None))
check('normal', solve(_vary(['a,b', 'x,y'])), _vary({'a': 'x', 'b': 'y'}))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
canonical names{'a': 'cell', 'b': ' y '}{'a': 'cell', 'b': ' y '}Passed
duplicate canonical{'a': 'y'}NoneFailed
empty headerNoneNonePassed
reserved headerNoneNonePassed
short rowNoneNonePassed
long rowNoneNonePassed
normal{'a': 'x', 'b': 'y'}{'a': 'x', 'b': 'y'}Passed

SHA-256 / a620d81eddf75d7bc47544253d8edc13b97e65ec39e2dc423674c5a9776357f3

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
def _vary(value):
    if value == '@END': return 3 + 4*N
    if isinstance(value, str): return value.replace('@', 'cell' * N)
    if isinstance(value, list): return [_vary(x) for x in value]
    if isinstance(value, dict): return {_vary(k): _vary(v) for k,v in value.items()}
    return value
N = 1
observations = []
def solve(data):
    headers = [h.strip().lower() for h in data[0].split(',')]
    values = data[1].split(',')
    if any(not h for h in headers): return None
    if len(set(headers)) != len(headers): return None
    if '_extra' in headers: return None
    if len(values) != len(headers): return None
    return dict(zip(headers, values))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('canonical names', solve(_vary([' A ,B', '@, y '])), _vary({'a': '@', 'b': ' y '}))
check('duplicate canonical', solve(_vary(['A,a', 'x,y'])), _vary(None))
check('empty header', solve(_vary(['a,', 'x,y'])), _vary(None))
check('reserved header', solve(_vary(['_extra,b', 'x,y'])), _vary(None))
check('short row', solve(_vary(['a,b', '@'])), _vary(None))
check('long row', solve(_vary(['a', 'x,y'])), _vary(None))
check('normal', solve(_vary(['a,b', 'x,y'])), _vary({'a': 'x', 'b': 'y'}))
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
canonical names{'a': 'cell', 'b': ' y '}{'a': 'cell', 'b': ' y '}Passed
duplicate canonicalNoneNonePassed
empty headerNoneNonePassed
reserved headerNoneNonePassed
short rowNoneNonePassed
long rowNoneNonePassed
normal{'a': 'x', 'b': 'y'}{'a': 'x', 'b': 'y'}Passed

SHA-256 / 50216bd5abca5160fea3b9512c15cdee50dba035faedc7567df31b012c704763

Verification & scope

Deterministic bounded in-memory model. No claim of complete CSV or external format conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:44:40.678610+00:00.

Case digest / f31626cd496288a377f50377c551ab85f69ce15676b6decc03ee754d9a13c6bd