FAILURE MAP
← Case archive

FA-47886 / Delimited text / Open access

Unknown record tags are treated as harmless metadata · 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

Unrecognized record kinds are skipped inside a closed grammar.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: else: return None

Unsuccessful approach: Treating unknown tags as data hides malformed framing.

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: 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: continue
    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 counted[]NoneFailed

SHA-256 / dfa385d59093c03b18032d3d944743189c3f54356a72eb593354879085620ab7

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: 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: rows.append(cells[1:])
    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 tag[['cell']]NoneFailed
bad widthNoneNonePassed
missing headerNoneNonePassed
second footerNoneNonePassed
bad countNoneNonePassed
unknown not countedNoneNonePassed

SHA-256 / 9464cb1d1fb55e38a5650e478522e9482a04d3fb1d1b9790120219d62d1f04a7

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

Case digest / c0f943660c5b6862cdf4790db7574513f48dc8be64a3a78e99b6946ca47d1fd7