FAILURE MAP
← Case archive

FA-48796 / Delimited text / Open access

The next CSV record starts on the prior ending physical line · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

The next CSV record starts on the prior ending physical line.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: start=end+1

Unsuccessful approach: The alternate implementation still violates the same declared invariant: the next csv record starts on the prior ending physical line.

Case contract

Parse bounded valid CSV text using Python csv.reader and report each logical row with inclusive one-based physical start/end line numbers. Quoted embedded newlines count as physical lines. Empty input gives no rows; blank physical lines are zero-cell rows. Return [start,end,cells].

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):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        out.append([start,end,cells])
        start=end
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
multiline[[1, 2, ['a', 'x\ny']], [2, 3, ['z', 'cell']]][[1, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]]Failed
blank middle[[1, 1, ['a']], [1, 2, []], [2, 3, ['z']]][[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]Failed
plain[[1, 1, ['cell', 'x']]][[1, 1, ['cell', 'x']]]Passed
CRLF[[1, 2, ['a\r\nb', 'z']]][[1, 2, ['a\r\nb', 'z']]]Passed
empty[][]Passed
unterminated final[[1, 1, ['cell']]][[1, 1, ['cell']]]Passed
two multiline[[1, 2, ['a\nb']], [2, 4, ['c\nd']]][[1, 2, ['a\nb']], [3, 4, ['c\nd']]]Failed

SHA-256 / d09800a28d30581ebef1b4d19df3272e3e81756773def4820fe8820787b2282e

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):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        out.append([start,end,cells])
        start+=1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
multiline[[1, 2, ['a', 'x\ny']], [2, 3, ['z', 'cell']]][[1, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]]Failed
blank middle[[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]][[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]Passed
plain[[1, 1, ['cell', 'x']]][[1, 1, ['cell', 'x']]]Passed
CRLF[[1, 2, ['a\r\nb', 'z']]][[1, 2, ['a\r\nb', 'z']]]Passed
empty[][]Passed
unterminated final[[1, 1, ['cell']]][[1, 1, ['cell']]]Passed
two multiline[[1, 2, ['a\nb']], [2, 4, ['c\nd']]][[1, 2, ['a\nb']], [3, 4, ['c\nd']]]Failed

SHA-256 / 0c6ec6f6113ddb242e35e60bf6e44e1b96586d961aaad3c9f066d9176ec63ad5

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):
    import csv,io
    reader=csv.reader(io.StringIO(data,newline=''))
    out=[]; start=1
    for cells in reader:
        end=reader.line_num
        out.append([start,end,cells])
        start=end+1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('multiline', solve(_vary('a,"x\ny"\nz,@\n')), _vary([[1, 2, ['a', 'x\ny']], [3, 3, ['z', '@']]]))
check('blank middle', solve(_vary('a\n\nz\n')), _vary([[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]))
check('plain', solve(_vary('@,x\n')), _vary([[1, 1, ['@', 'x']]]))
check('CRLF', solve(_vary('"a\r\nb",z\r\n')), _vary([[1, 2, ['a\r\nb', 'z']]]))
check('empty', solve(_vary('')), _vary([]))
check('unterminated final', solve(_vary('@')), _vary([[1, 1, ['@']]]))
check('two multiline', solve(_vary('"a\nb"\n"c\nd"')), _vary([[1, 2, ['a\nb']], [3, 4, ['c\nd']]]))
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
multiline[[1, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]][[1, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]]Passed
blank middle[[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]][[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]Passed
plain[[1, 1, ['cell', 'x']]][[1, 1, ['cell', 'x']]]Passed
CRLF[[1, 2, ['a\r\nb', 'z']]][[1, 2, ['a\r\nb', 'z']]]Passed
empty[][]Passed
unterminated final[[1, 1, ['cell']]][[1, 1, ['cell']]]Passed
two multiline[[1, 2, ['a\nb']], [3, 4, ['c\nd']]][[1, 2, ['a\nb']], [3, 4, ['c\nd']]]Passed

SHA-256 / c0dcd833e59189ee8c02f058ae4196f72cb98eb308059eff0a5c0abb27b2d4b0

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

Case digest / 788b8906ea35994c0bb4c359f9eb75fcd55be2b7d8d786efb9d0159ade04ffd3