FAILURE MAP
← Case archive

FA-48766 / Delimited text / Open access

A new chunk overwrites the unfinished preceding record · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

A new chunk overwrites the unfinished preceding record.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: carry+=chunk

Unsuccessful approach: The alternate implementation still violates the same declared invariant: a new chunk overwrites the unfinished preceding record.

Case contract

Consume arbitrary text chunks of an unquoted LF-delimited table. Complete records emit immediately into an output list; carry partial records across chunks. EOF emits a nonempty remaining fragment, but not a phantom row after final LF. Empty complete physical records are retained. Return comma-split rows.

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):
    rows=[]; carry=''
    for chunk in data:
        carry=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['a'], ['b']]))
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
split cell[[''], ['x', 'y']][['a', 'cell'], ['x', 'y']]Failed
several per chunk[['a', 'b'], ['cell', 'z']][['a', 'b'], ['cell', 'z']]Passed
empty chunks[['']][['cell']]Failed
partial final[['a', 'b'], ['cell']][['a', 'b'], ['cell']]Passed
empty rows[[''], ['']][[''], ['']]Passed
empty input[][]Passed
no newline[['cell']][['cell']]Passed
split delimiter[[''], ['b']][['a'], ['b']]Failed

SHA-256 / 52eebe140cd8ad0f1722de6a2912395a8fdcb19b481c60e5a9aaee014a184e24

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):
    rows=[]; carry=''
    for chunk in data:
        carry=chunk+carry
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['a'], ['b']]))
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
split cell[[''], ['x', 'y'], ['cella', '']][['a', 'cell'], ['x', 'y']]Failed
several per chunk[['a', 'b'], ['cell', 'z']][['a', 'b'], ['cell', 'z']]Passed
empty chunks[[''], ['cell']][['cell']]Failed
partial final[['a', 'b'], ['cell']][['a', 'b'], ['cell']]Passed
empty rows[[''], ['']][[''], ['']]Passed
empty input[][]Passed
no newline[['cell']][['cell']]Passed
split delimiter[[''], ['ba']][['a'], ['b']]Failed

SHA-256 / b799f676be7dcc585d97874f8f07aee0029fe144f1871a875e7bc1aa36483ba0

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):
    rows=[]; carry=''
    for chunk in data:
        carry+=chunk
        while '\n' in carry:
            record,carry=carry.split('\n',1)
            rows.append(record.split(','))
    if carry: rows.append(carry.split(','))
    return rows
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('split cell', solve(_vary(['a,', '@', '\nx,y\n'])), _vary([['a', '@'], ['x', 'y']]))
check('several per chunk', solve(_vary(['a,b\n@,z\n'])), _vary([['a', 'b'], ['@', 'z']]))
check('empty chunks', solve(_vary(['', '@', '', '\n', ''])), _vary([['@']]))
check('partial final', solve(_vary(['a,b\n@'])), _vary([['a', 'b'], ['@']]))
check('empty rows', solve(_vary(['\n\n'])), _vary([[''], ['']]))
check('empty input', solve(_vary([])), _vary([]))
check('no newline', solve(_vary(['@'])), _vary([['@']]))
check('split delimiter', solve(_vary(['a', '\n', 'b'])), _vary([['a'], ['b']]))
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
split cell[['a', 'cell'], ['x', 'y']][['a', 'cell'], ['x', 'y']]Passed
several per chunk[['a', 'b'], ['cell', 'z']][['a', 'b'], ['cell', 'z']]Passed
empty chunks[['cell']][['cell']]Passed
partial final[['a', 'b'], ['cell']][['a', 'b'], ['cell']]Passed
empty rows[[''], ['']][[''], ['']]Passed
empty input[][]Passed
no newline[['cell']][['cell']]Passed
split delimiter[['a'], ['b']][['a'], ['b']]Passed

SHA-256 / 85410585cfb2fad32494d3b27709ac40176364ac6f648ab54678ed08bd179c6b

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

Case digest / 12a4e9a112f036c302270ebfc1780858024afaf0a9640a6bbd0d70c1ba2ac289