FAILURE MAP
← Case archive

FA-47381 / Delimited text / Open access

Repeated-header imports accept ambiguous initial schema · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

Initial schema uniqueness is never established.

VERIFIED REPAIR

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

Unsuccessful approach: Rejecting an empty schema cannot discover duplicate named columns.

Case contract

Parse nonempty comma records with a first header. Skip later records only when the complete row equals the initial header; reject duplicate first header names, data before a header, and data width mismatches. Blank physical lines are ignored.

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):
    lines = [line for line in data.split('\n') if line != '']
    if not lines: return []
    header = lines[0].split(',')
    if False: return None
    out = []
    for line in lines[1:]:
        row = line.split(',')
        if row == header: continue
        if len(row) != len(header): return None
        out.append(row)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeated', solve(_vary('a,b\n@,z\na,b\nx,y')), _vary([['@', 'z'], ['x', 'y']]))
check('partial', solve(_vary('a,b\na,y')), _vary([['a', 'y']]))
check('empty', solve(_vary('')), _vary([]))
check('blank', solve(_vary('a,b\n\n@,z')), _vary([['@', 'z']]))
check('duplicates', solve(_vary('a,a\nx,y')), _vary(None))
check('wide', solve(_vary('a,b\nx,y,z')), _vary(None))
check('narrow', solve(_vary('a,b\nx')), _vary(None))
check('header only', solve(_vary('a,b')), _vary([]))
check('trailing blank', solve(_vary('a,b\n@,z\n')), _vary([['@', 'z']]))
check('permuted header cells', solve(_vary('a,b\nb,a')), _vary([['b', 'a']]))
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
repeated[['cell', 'z'], ['x', 'y']][['cell', 'z'], ['x', 'y']]Passed
partial[['a', 'y']][['a', 'y']]Passed
empty[][]Passed
blank[['cell', 'z']][['cell', 'z']]Passed
duplicates[['x', 'y']]NoneFailed
wideNoneNonePassed
narrowNoneNonePassed
header only[][]Passed
trailing blank[['cell', 'z']][['cell', 'z']]Passed
permuted header cells[['b', 'a']][['b', 'a']]Passed

SHA-256 / 7633a71b800fe871a5e02513eda3a8766ee5dcbbc840b66bca8f2f338fe22cbf

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):
    lines = [line for line in data.split('\n') if line != '']
    if not lines: return []
    header = lines[0].split(',')
    if header == ['']: return None
    out = []
    for line in lines[1:]:
        row = line.split(',')
        if row == header: continue
        if len(row) != len(header): return None
        out.append(row)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeated', solve(_vary('a,b\n@,z\na,b\nx,y')), _vary([['@', 'z'], ['x', 'y']]))
check('partial', solve(_vary('a,b\na,y')), _vary([['a', 'y']]))
check('empty', solve(_vary('')), _vary([]))
check('blank', solve(_vary('a,b\n\n@,z')), _vary([['@', 'z']]))
check('duplicates', solve(_vary('a,a\nx,y')), _vary(None))
check('wide', solve(_vary('a,b\nx,y,z')), _vary(None))
check('narrow', solve(_vary('a,b\nx')), _vary(None))
check('header only', solve(_vary('a,b')), _vary([]))
check('trailing blank', solve(_vary('a,b\n@,z\n')), _vary([['@', 'z']]))
check('permuted header cells', solve(_vary('a,b\nb,a')), _vary([['b', 'a']]))
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
repeated[['cell', 'z'], ['x', 'y']][['cell', 'z'], ['x', 'y']]Passed
partial[['a', 'y']][['a', 'y']]Passed
empty[][]Passed
blank[['cell', 'z']][['cell', 'z']]Passed
duplicates[['x', 'y']]NoneFailed
wideNoneNonePassed
narrowNoneNonePassed
header only[][]Passed
trailing blank[['cell', 'z']][['cell', 'z']]Passed
permuted header cells[['b', 'a']][['b', 'a']]Passed

SHA-256 / df5705a730be4e038b445010942214a32f99840cddf58630677398e186f272c1

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):
    lines = [line for line in data.split('\n') if line != '']
    if not lines: return []
    header = lines[0].split(',')
    if len(set(header)) != len(header): return None
    out = []
    for line in lines[1:]:
        row = line.split(',')
        if row == header: continue
        if len(row) != len(header): return None
        out.append(row)
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('repeated', solve(_vary('a,b\n@,z\na,b\nx,y')), _vary([['@', 'z'], ['x', 'y']]))
check('partial', solve(_vary('a,b\na,y')), _vary([['a', 'y']]))
check('empty', solve(_vary('')), _vary([]))
check('blank', solve(_vary('a,b\n\n@,z')), _vary([['@', 'z']]))
check('duplicates', solve(_vary('a,a\nx,y')), _vary(None))
check('wide', solve(_vary('a,b\nx,y,z')), _vary(None))
check('narrow', solve(_vary('a,b\nx')), _vary(None))
check('header only', solve(_vary('a,b')), _vary([]))
check('trailing blank', solve(_vary('a,b\n@,z\n')), _vary([['@', 'z']]))
check('permuted header cells', solve(_vary('a,b\nb,a')), _vary([['b', 'a']]))
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
repeated[['cell', 'z'], ['x', 'y']][['cell', 'z'], ['x', 'y']]Passed
partial[['a', 'y']][['a', 'y']]Passed
empty[][]Passed
blank[['cell', 'z']][['cell', 'z']]Passed
duplicatesNoneNonePassed
wideNoneNonePassed
narrowNoneNonePassed
header only[][]Passed
trailing blank[['cell', 'z']][['cell', 'z']]Passed
permuted header cells[['b', 'a']][['b', 'a']]Passed

SHA-256 / f360b808b146bdee2cc1bd3528e596ddccba1f079f2fff0159ca59855ba9ae6d

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.907469+00:00.

Case digest / 45f35471e1d610c1320d7587bb19c9193389baf094c7f2d8235a42f458a3aabf