FAILURE MAP
← Case archive

FA-47876 / Delimited text / Open access

A footer does not prevent later data records · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

Records after the terminal declaration are silently ignored.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if closed: return None

Unsuccessful approach: Reopening after a footer instead admits appended data.

Case contract

Read a comma table with header H,<column names>, body D,<values>, and final F,<body count>. Reject missing or misplaced footer, count mismatch, malformed tags, unequal body width, and missing header. Count only body records. Return body arrays.

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):
    if not data or not data[0].startswith('H,'): return None
    width = len(data[0].split(',')) - 1
    rows, closed = [], False
    for line in data[1:]:
        if closed: continue
        cells = line.split(',')
        if cells[0] == 'D':
            if len(cells) - 1 != width: return None
            rows.append(cells[1:])
        elif cells[0] == 'F':
            if len(cells) != 2 or not cells[1].isascii() or not cells[1].isdecimal(): return None
            if int(cells[1]) != len(rows): return None
            closed = True
        else: return None
    if not closed: return None
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('table', solve(_vary(['H,a,b', 'D,@,x', 'D,y,z', 'F,2'])), _vary([['@', 'x'], ['y', 'z']]))
check('count mismatch', solve(_vary(['H,a', 'D,@', 'F,2'])), _vary(None))
check('after footer', solve(_vary(['H,a', 'F,0', 'D,@'])), _vary(None))
check('missing footer', solve(_vary(['H,a', 'D,@'])), _vary(None))
check('empty body', solve(_vary(['H,a', 'F,0'])), _vary([]))
check('bad tag', solve(_vary(['H,a', 'X,@', 'F,1'])), _vary(None))
check('bad width', solve(_vary(['H,a,b', 'D,@', 'F,1'])), _vary(None))
check('missing header', solve(_vary(['D,@', 'F,1'])), _vary(None))
check('second footer', solve(_vary(['H,a', 'F,0', 'F,0'])), _vary(None))
check('bad count', solve(_vary(['H,a', 'F,-1'])), _vary(None))
check('unknown not counted', solve(_vary(['H,a', 'X,@', 'F,0'])), _vary(None))
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
table[['cell', 'x'], ['y', 'z']][['cell', 'x'], ['y', 'z']]Passed
count mismatchNoneNonePassed
after footer[]NoneFailed
missing footerNoneNonePassed
empty body[][]Passed
bad tagNoneNonePassed
bad widthNoneNonePassed
missing headerNoneNonePassed
second footer[]NoneFailed
bad countNoneNonePassed
unknown not countedNoneNonePassed

SHA-256 / 642c305aa420adc51b592463f798808562f29b846f9f683e920c68f5463eb17c

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):
    if not data or not data[0].startswith('H,'): return None
    width = len(data[0].split(',')) - 1
    rows, closed = [], False
    for line in data[1:]:
        if closed: closed = False
        cells = line.split(',')
        if cells[0] == 'D':
            if len(cells) - 1 != width: return None
            rows.append(cells[1:])
        elif cells[0] == 'F':
            if len(cells) != 2 or not cells[1].isascii() or not cells[1].isdecimal(): return None
            if int(cells[1]) != len(rows): return None
            closed = True
        else: return None
    if not closed: return None
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('table', solve(_vary(['H,a,b', 'D,@,x', 'D,y,z', 'F,2'])), _vary([['@', 'x'], ['y', 'z']]))
check('count mismatch', solve(_vary(['H,a', 'D,@', 'F,2'])), _vary(None))
check('after footer', solve(_vary(['H,a', 'F,0', 'D,@'])), _vary(None))
check('missing footer', solve(_vary(['H,a', 'D,@'])), _vary(None))
check('empty body', solve(_vary(['H,a', 'F,0'])), _vary([]))
check('bad tag', solve(_vary(['H,a', 'X,@', 'F,1'])), _vary(None))
check('bad width', solve(_vary(['H,a,b', 'D,@', 'F,1'])), _vary(None))
check('missing header', solve(_vary(['D,@', 'F,1'])), _vary(None))
check('second footer', solve(_vary(['H,a', 'F,0', 'F,0'])), _vary(None))
check('bad count', solve(_vary(['H,a', 'F,-1'])), _vary(None))
check('unknown not counted', solve(_vary(['H,a', 'X,@', 'F,0'])), _vary(None))
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
table[['cell', 'x'], ['y', 'z']][['cell', 'x'], ['y', 'z']]Passed
count mismatchNoneNonePassed
after footerNoneNonePassed
missing footerNoneNonePassed
empty body[][]Passed
bad tagNoneNonePassed
bad widthNoneNonePassed
missing headerNoneNonePassed
second footer[]NoneFailed
bad countNoneNonePassed
unknown not countedNoneNonePassed

SHA-256 / 83eaccb93d29033d3a5462229b8df838c4f64fa4c8c34c6a631717ae55b7f917

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):
    if not data or not data[0].startswith('H,'): return None
    width = len(data[0].split(',')) - 1
    rows, closed = [], False
    for line in data[1:]:
        if closed: return None
        cells = line.split(',')
        if cells[0] == 'D':
            if len(cells) - 1 != width: return None
            rows.append(cells[1:])
        elif cells[0] == 'F':
            if len(cells) != 2 or not cells[1].isascii() or not cells[1].isdecimal(): return None
            if int(cells[1]) != len(rows): return None
            closed = True
        else: return None
    if not closed: return None
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('table', solve(_vary(['H,a,b', 'D,@,x', 'D,y,z', 'F,2'])), _vary([['@', 'x'], ['y', 'z']]))
check('count mismatch', solve(_vary(['H,a', 'D,@', 'F,2'])), _vary(None))
check('after footer', solve(_vary(['H,a', 'F,0', 'D,@'])), _vary(None))
check('missing footer', solve(_vary(['H,a', 'D,@'])), _vary(None))
check('empty body', solve(_vary(['H,a', 'F,0'])), _vary([]))
check('bad tag', solve(_vary(['H,a', 'X,@', 'F,1'])), _vary(None))
check('bad width', solve(_vary(['H,a,b', 'D,@', 'F,1'])), _vary(None))
check('missing header', solve(_vary(['D,@', 'F,1'])), _vary(None))
check('second footer', solve(_vary(['H,a', 'F,0', 'F,0'])), _vary(None))
check('bad count', solve(_vary(['H,a', 'F,-1'])), _vary(None))
check('unknown not counted', solve(_vary(['H,a', 'X,@', 'F,0'])), _vary(None))
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
table[['cell', 'x'], ['y', 'z']][['cell', 'x'], ['y', 'z']]Passed
count mismatchNoneNonePassed
after footerNoneNonePassed
missing footerNoneNonePassed
empty body[][]Passed
bad tagNoneNonePassed
bad widthNoneNonePassed
missing headerNoneNonePassed
second footerNoneNonePassed
bad countNoneNonePassed
unknown not countedNoneNonePassed

SHA-256 / eff4fab36227655b39d1b05e0a3920c4258817e46c396a4ac93252451db6c6e7

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

Case digest / 5b03306b54280e1b8ed4a206aa23773485bcff4765023bf78b0be6a3d68f80af