FAILURE MAP
← Case archive

FA-48801 / Delimited text / Open access

CSV physical line provenance starts from zero · 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

CSV physical line provenance starts from zero.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: out=[]; start=1

Unsuccessful approach: The alternate implementation still violates the same declared invariant: csv physical line provenance starts from zero.

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=0
    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[[0, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]][[1, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]]Failed
blank middle[[0, 1, ['a']], [2, 2, []], [3, 3, ['z']]][[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]Failed
plain[[0, 1, ['cell', 'x']]][[1, 1, ['cell', 'x']]]Failed
CRLF[[0, 2, ['a\r\nb', 'z']]][[1, 2, ['a\r\nb', 'z']]]Failed
empty[][]Passed
unterminated final[[0, 1, ['cell']]][[1, 1, ['cell']]]Failed
two multiline[[0, 2, ['a\nb']], [3, 4, ['c\nd']]][[1, 2, ['a\nb']], [3, 4, ['c\nd']]]Failed

SHA-256 / 9ec74c49dd706e5db9c1d8a357b4f64a0d171a33185d5c68c7a5606f72c6a7b0

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=2
    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[[2, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]][[1, 2, ['a', 'x\ny']], [3, 3, ['z', 'cell']]]Failed
blank middle[[2, 1, ['a']], [2, 2, []], [3, 3, ['z']]][[1, 1, ['a']], [2, 2, []], [3, 3, ['z']]]Failed
plain[[2, 1, ['cell', 'x']]][[1, 1, ['cell', 'x']]]Failed
CRLF[[2, 2, ['a\r\nb', 'z']]][[1, 2, ['a\r\nb', 'z']]]Failed
empty[][]Passed
unterminated final[[2, 1, ['cell']]][[1, 1, ['cell']]]Failed
two multiline[[2, 2, ['a\nb']], [3, 4, ['c\nd']]][[1, 2, ['a\nb']], [3, 4, ['c\nd']]]Failed

SHA-256 / 6cbc770ad360511268e17e31da2206e7ddc22df65a4af9b8785a87bc22ef4103

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

Case digest / 0dfa5a09971c63658ba0115be930a503c5f0885a86e74b0cc8d5f05552f7f2f6