FA-47966 / Delimited text / Open access
Quarantine errors use zero-based source record numbers · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
The diagnostic position leaks an internal array index.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: enumerate(data['lines'], 1)
Unsuccessful approach: Adding a header offset despite an external header shifts every source location.
Case contract
Import three-column comma rows with exact modes strict, skip, or collect. Width failures are 1-based source record positions. Strict returns {error:position}; skip omits bad rows; collect returns valid rows and errors containing position and original cells. Header is supplied separately and not counted.
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, errors = [], []
for position,line in enumerate(data['lines']):
cells = line.split(',')
if len(cells) != 3:
if data['mode'] == 'strict': return {'error':position}
if data['mode'] == 'collect': errors.append([position, cells])
continue
rows.append(cells)
return {'rows':rows, 'errors':errors}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('collect', solve(_vary({'mode': 'collect', 'lines': ['@,a,b', 'x,y', 'c,d,e', 'z']})), _vary({'rows': [['@', 'a', 'b'], ['c', 'd', 'e']], 'errors': [[2, ['x', 'y']], [4, ['z']]]}))
check('strict', solve(_vary({'mode': 'strict', 'lines': ['@,a,b', 'x,y', 'c,d,e']})), _vary({'error': 2}))
check('skip', solve(_vary({'mode': 'skip', 'lines': ['x,y', '@,a,b', 'z']})), _vary({'rows': [['@', 'a', 'b']], 'errors': []}))
check('normal', solve(_vary({'mode': 'strict', 'lines': ['@,a,b']})), _vary({'rows': [['@', 'a', 'b']], 'errors': []}))
check('empty', solve(_vary({'mode': 'collect', 'lines': []})), _vary({'rows': [], 'errors': []}))
check('empty cells', solve(_vary({'mode': 'collect', 'lines': [',,']})), _vary({'rows': [['', '', '']], 'errors': []}))
check('wide', solve(_vary({'mode': 'collect', 'lines': ['a,b,c,d']})), _vary({'rows': [], 'errors': [[1, ['a', 'b', 'c', 'd']]]}))
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 |
|---|---|---|---|
| collect | {'errors': [[1, ['x', 'y']], [3, ['z']]], 'rows': [['cell', 'a', 'b'], ['c', 'd', 'e']]} | {'errors': [[2, ['x', 'y']], [4, ['z']]], 'rows': [['cell', 'a', 'b'], ['c', 'd', 'e']]} | Failed |
| strict | {'error': 1} | {'error': 2} | Failed |
| skip | {'errors': [], 'rows': [['cell', 'a', 'b']]} | {'errors': [], 'rows': [['cell', 'a', 'b']]} | Passed |
| normal | {'errors': [], 'rows': [['cell', 'a', 'b']]} | {'errors': [], 'rows': [['cell', 'a', 'b']]} | Passed |
| empty | {'errors': [], 'rows': []} | {'errors': [], 'rows': []} | Passed |
| empty cells | {'errors': [], 'rows': [['', '', '']]} | {'errors': [], 'rows': [['', '', '']]} | Passed |
| wide | {'errors': [[0, ['a', 'b', 'c', 'd']]], 'rows': []} | {'errors': [[1, ['a', 'b', 'c', 'd']]], 'rows': []} | Failed |
SHA-256 / 9e551470ecf50c863ed39a6674ce2036de63a3704a3657509eef36cf2b4a876f
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, errors = [], []
for position,line in enumerate(data['lines'], 2):
cells = line.split(',')
if len(cells) != 3:
if data['mode'] == 'strict': return {'error':position}
if data['mode'] == 'collect': errors.append([position, cells])
continue
rows.append(cells)
return {'rows':rows, 'errors':errors}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('collect', solve(_vary({'mode': 'collect', 'lines': ['@,a,b', 'x,y', 'c,d,e', 'z']})), _vary({'rows': [['@', 'a', 'b'], ['c', 'd', 'e']], 'errors': [[2, ['x', 'y']], [4, ['z']]]}))
check('strict', solve(_vary({'mode': 'strict', 'lines': ['@,a,b', 'x,y', 'c,d,e']})), _vary({'error': 2}))
check('skip', solve(_vary({'mode': 'skip', 'lines': ['x,y', '@,a,b', 'z']})), _vary({'rows': [['@', 'a', 'b']], 'errors': []}))
check('normal', solve(_vary({'mode': 'strict', 'lines': ['@,a,b']})), _vary({'rows': [['@', 'a', 'b']], 'errors': []}))
check('empty', solve(_vary({'mode': 'collect', 'lines': []})), _vary({'rows': [], 'errors': []}))
check('empty cells', solve(_vary({'mode': 'collect', 'lines': [',,']})), _vary({'rows': [['', '', '']], 'errors': []}))
check('wide', solve(_vary({'mode': 'collect', 'lines': ['a,b,c,d']})), _vary({'rows': [], 'errors': [[1, ['a', 'b', 'c', 'd']]]}))
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 |
|---|---|---|---|
| collect | {'errors': [[3, ['x', 'y']], [5, ['z']]], 'rows': [['cell', 'a', 'b'], ['c', 'd', 'e']]} | {'errors': [[2, ['x', 'y']], [4, ['z']]], 'rows': [['cell', 'a', 'b'], ['c', 'd', 'e']]} | Failed |
| strict | {'error': 3} | {'error': 2} | Failed |
| skip | {'errors': [], 'rows': [['cell', 'a', 'b']]} | {'errors': [], 'rows': [['cell', 'a', 'b']]} | Passed |
| normal | {'errors': [], 'rows': [['cell', 'a', 'b']]} | {'errors': [], 'rows': [['cell', 'a', 'b']]} | Passed |
| empty | {'errors': [], 'rows': []} | {'errors': [], 'rows': []} | Passed |
| empty cells | {'errors': [], 'rows': [['', '', '']]} | {'errors': [], 'rows': [['', '', '']]} | Passed |
| wide | {'errors': [[2, ['a', 'b', 'c', 'd']]], 'rows': []} | {'errors': [[1, ['a', 'b', 'c', 'd']]], 'rows': []} | Failed |
SHA-256 / bed902b3f06217be14aa05285df3497d8176445efa684445cb7e5d1ceb87bf3a
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, errors = [], []
for position,line in enumerate(data['lines'], 1):
cells = line.split(',')
if len(cells) != 3:
if data['mode'] == 'strict': return {'error':position}
if data['mode'] == 'collect': errors.append([position, cells])
continue
rows.append(cells)
return {'rows':rows, 'errors':errors}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('collect', solve(_vary({'mode': 'collect', 'lines': ['@,a,b', 'x,y', 'c,d,e', 'z']})), _vary({'rows': [['@', 'a', 'b'], ['c', 'd', 'e']], 'errors': [[2, ['x', 'y']], [4, ['z']]]}))
check('strict', solve(_vary({'mode': 'strict', 'lines': ['@,a,b', 'x,y', 'c,d,e']})), _vary({'error': 2}))
check('skip', solve(_vary({'mode': 'skip', 'lines': ['x,y', '@,a,b', 'z']})), _vary({'rows': [['@', 'a', 'b']], 'errors': []}))
check('normal', solve(_vary({'mode': 'strict', 'lines': ['@,a,b']})), _vary({'rows': [['@', 'a', 'b']], 'errors': []}))
check('empty', solve(_vary({'mode': 'collect', 'lines': []})), _vary({'rows': [], 'errors': []}))
check('empty cells', solve(_vary({'mode': 'collect', 'lines': [',,']})), _vary({'rows': [['', '', '']], 'errors': []}))
check('wide', solve(_vary({'mode': 'collect', 'lines': ['a,b,c,d']})), _vary({'rows': [], 'errors': [[1, ['a', 'b', 'c', 'd']]]}))
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 |
|---|---|---|---|
| collect | {'errors': [[2, ['x', 'y']], [4, ['z']]], 'rows': [['cell', 'a', 'b'], ['c', 'd', 'e']]} | {'errors': [[2, ['x', 'y']], [4, ['z']]], 'rows': [['cell', 'a', 'b'], ['c', 'd', 'e']]} | Passed |
| strict | {'error': 2} | {'error': 2} | Passed |
| skip | {'errors': [], 'rows': [['cell', 'a', 'b']]} | {'errors': [], 'rows': [['cell', 'a', 'b']]} | Passed |
| normal | {'errors': [], 'rows': [['cell', 'a', 'b']]} | {'errors': [], 'rows': [['cell', 'a', 'b']]} | Passed |
| empty | {'errors': [], 'rows': []} | {'errors': [], 'rows': []} | Passed |
| empty cells | {'errors': [], 'rows': [['', '', '']]} | {'errors': [], 'rows': [['', '', '']]} | Passed |
| wide | {'errors': [[1, ['a', 'b', 'c', 'd']]], 'rows': []} | {'errors': [[1, ['a', 'b', 'c', 'd']]], 'rows': []} | Passed |
SHA-256 / 7174d4ccd4148028e0bac6342bad2cdc7ca8bbc1aff2fedd176eeeaa8473631f
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:46.407983+00:00.
Case digest / 82a0793a0e02c60f183412f710fb1bb04374270c8153d811bf815aad98c81d31