FAILURE MAP
← Case archive

FA-48081 / Delimited text / Open access

A final record delimiter produces a phantom empty record · 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 terminal split artifact is treated as a physical record.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if parts[-1] == '': parts.pop()

Unsuccessful approach: Removing only the empty-document artifact misses trailing LF after data.

Case contract

For UTF-8 text with LF-delimited physical records, report each record as [text,start_byte,end_byte,line_number]. LF is excluded from text and end offset; a final LF does not add a phantom record. Empty interior records remain. Leading BOM is ordinary text here.

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):
    out, start, line = [], 0, 1
    parts = data.split('\n')
    if False: parts.pop()
    for text in parts:
        size = len(text.encode('utf-8'))
        out.append([text, start, start + size, line])
        start += size + 1
        line += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unicode', solve(_vary('é\n@')), _vary([['é', 0, 2, 1], ['@', 3, '@END', 2]]))
check('empty middle', solve(_vary('a\n\nb')), _vary([['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]))
check('final LF', solve(_vary('a\n')), _vary([['a', 0, 1, 1]]))
check('empty', solve(_vary('')), _vary([]))
check('only LF', solve(_vary('\n')), _vary([['', 0, 0, 1]]))
check('astral', solve(_vary('😀\nz')), _vary([['😀', 0, 4, 1], ['z', 5, 6, 2]]))
check('no LF', solve(_vary('x')), _vary([['x', 0, 1, 1]]))
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
unicode[['é', 0, 2, 1], ['cell', 3, 7, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Passed
empty middle[['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Passed
final LF[['a', 0, 1, 1], ['', 2, 2, 2]][['a', 0, 1, 1]]Failed
empty[['', 0, 0, 1]][]Failed
only LF[['', 0, 0, 1], ['', 1, 1, 2]][['', 0, 0, 1]]Failed
astral[['😀', 0, 4, 1], ['z', 5, 6, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Passed
no LF[['x', 0, 1, 1]][['x', 0, 1, 1]]Passed

SHA-256 / 72c6cabac3cb7a17a700068ce319eb575a7bc1fffc557710694115d93805333a

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):
    out, start, line = [], 0, 1
    parts = data.split('\n')
    if len(parts) == 1 and parts[-1] == '': parts.pop()
    for text in parts:
        size = len(text.encode('utf-8'))
        out.append([text, start, start + size, line])
        start += size + 1
        line += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unicode', solve(_vary('é\n@')), _vary([['é', 0, 2, 1], ['@', 3, '@END', 2]]))
check('empty middle', solve(_vary('a\n\nb')), _vary([['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]))
check('final LF', solve(_vary('a\n')), _vary([['a', 0, 1, 1]]))
check('empty', solve(_vary('')), _vary([]))
check('only LF', solve(_vary('\n')), _vary([['', 0, 0, 1]]))
check('astral', solve(_vary('😀\nz')), _vary([['😀', 0, 4, 1], ['z', 5, 6, 2]]))
check('no LF', solve(_vary('x')), _vary([['x', 0, 1, 1]]))
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
unicode[['é', 0, 2, 1], ['cell', 3, 7, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Passed
empty middle[['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Passed
final LF[['a', 0, 1, 1], ['', 2, 2, 2]][['a', 0, 1, 1]]Failed
empty[][]Passed
only LF[['', 0, 0, 1], ['', 1, 1, 2]][['', 0, 0, 1]]Failed
astral[['😀', 0, 4, 1], ['z', 5, 6, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Passed
no LF[['x', 0, 1, 1]][['x', 0, 1, 1]]Passed

SHA-256 / 7fa7d381a77fe02b9ffed2861ad9e6236fd529c3535b600080f7039fabd9708a

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):
    out, start, line = [], 0, 1
    parts = data.split('\n')
    if parts[-1] == '': parts.pop()
    for text in parts:
        size = len(text.encode('utf-8'))
        out.append([text, start, start + size, line])
        start += size + 1
        line += 1
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unicode', solve(_vary('é\n@')), _vary([['é', 0, 2, 1], ['@', 3, '@END', 2]]))
check('empty middle', solve(_vary('a\n\nb')), _vary([['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]))
check('final LF', solve(_vary('a\n')), _vary([['a', 0, 1, 1]]))
check('empty', solve(_vary('')), _vary([]))
check('only LF', solve(_vary('\n')), _vary([['', 0, 0, 1]]))
check('astral', solve(_vary('😀\nz')), _vary([['😀', 0, 4, 1], ['z', 5, 6, 2]]))
check('no LF', solve(_vary('x')), _vary([['x', 0, 1, 1]]))
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
unicode[['é', 0, 2, 1], ['cell', 3, 7, 2]][['é', 0, 2, 1], ['cell', 3, 7, 2]]Passed
empty middle[['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]][['a', 0, 1, 1], ['', 2, 2, 2], ['b', 3, 4, 3]]Passed
final LF[['a', 0, 1, 1]][['a', 0, 1, 1]]Passed
empty[][]Passed
only LF[['', 0, 0, 1]][['', 0, 0, 1]]Passed
astral[['😀', 0, 4, 1], ['z', 5, 6, 2]][['😀', 0, 4, 1], ['z', 5, 6, 2]]Passed
no LF[['x', 0, 1, 1]][['x', 0, 1, 1]]Passed

SHA-256 / 5a6882ff32edfacc4f2d66200eb1f89df8b3f59bdc8b43ded53608af400d1d63

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

Case digest / e4f0f74b28843236bfadc2f8f5b926435ce538522d8ca17f99fe66a4b2d147d0