FA-48786 / Delimited text / Open access
Complete blank records are removed while draining chunks · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
Complete blank records are removed while draining chunks.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: rows.append(record.split(','))
Unsuccessful approach: The alternate implementation still violates the same declared invariant: complete blank records are removed while draining chunks.
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)
if record: 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | [] | [[''], ['']] | Failed |
| empty input | [] | [] | Passed |
| no newline | [['cell']] | [['cell']] | Passed |
| split delimiter | [['a'], ['b']] | [['a'], ['b']] | Passed |
SHA-256 / 3c2afa3029e33533c168a501c994ac1ff8d36f2163c2a132bf8d4c6489b9b37c
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
while '\n' in carry:
record,carry=carry.split('\n',1)
if record.strip(): 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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 | [] | [[''], ['']] | Failed |
| empty input | [] | [] | Passed |
| no newline | [['cell']] | [['cell']] | Passed |
| split delimiter | [['a'], ['b']] | [['a'], ['b']] | Passed |
SHA-256 / 98af236daa841f6ef7a0eec50016f8bf3c41c3d1b857b4d7b46145efd24a950f
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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.899598+00:00.
Case digest / 65715611da20ba8c5a4ba9e3b8f2ed8cb50bada5dab81ab0776d13bb331b0bb7