FAILURE MAP
← Case archive

FA-47846 / Delimited text / Open access

The separator preamble is emitted as a data row · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

Recognizing the separator does not remove the metadata record.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: value = lines.pop(0)[4:]

Unsuccessful approach: Popping the final record removes data and reads the wrong delimiter.

Case contract

Read a table with optional exact first line sep=<single nonquote, nonnewline character>. A first-line BOM is removed before recognizing this directive. Without directive use comma. The directive is not data. Later sep= lines are ordinary records. Return delimiter and split records; empty input has no records.

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):
    lines = list(data)
    if not lines: return [',', []]
    if lines[0].startswith('\ufeff'): lines[0] = lines[0][1:]
    delimiter = ','
    if lines[0].startswith('sep='):
        value = lines[0][4:]
        if len(value) != 1 or value in '\r\n"': return None
        delimiter = value
    return [delimiter, [line.split(delimiter) for line in lines]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('custom', solve(_vary(['sep=;', '@;x'])), _vary([';', [['@', 'x']]]))
check('BOM directive', solve(_vary(['\ufeffsep=;', '@;x'])), _vary([';', [['@', 'x']]]))
check('default', solve(_vary(['@,x'])), _vary([',', [['@', 'x']]]))
check('later directive', solve(_vary(['a,b', 'sep=;'])), _vary([',', [['a', 'b'], ['sep=;']]]))
check('bad multi', solve(_vary(['sep=;;', 'x'])), _vary(None))
check('bad quote', solve(_vary(['sep="', 'x'])), _vary(None))
check('empty marker', solve(_vary(['sep=', 'x'])), _vary(None))
check('directive only', solve(_vary(['sep=;'])), _vary([';', []]))
check('zero', solve(_vary([])), _vary([',', []]))
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
custom[';', [['sep=', ''], ['cell', 'x']]][';', [['cell', 'x']]]Failed
BOM directive[';', [['sep=', ''], ['cell', 'x']]][';', [['cell', 'x']]]Failed
default[',', [['cell', 'x']]][',', [['cell', 'x']]]Passed
later directive[',', [['a', 'b'], ['sep=;']]][',', [['a', 'b'], ['sep=;']]]Passed
bad multiNoneNonePassed
bad quoteNoneNonePassed
empty markerNoneNonePassed
directive only[';', [['sep=', '']]][';', []]Failed
zero[',', []][',', []]Passed

SHA-256 / 77ba66647db1fd425e21fb4a81c143055e8c146ca5d326370e3cd3ea584fd006

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):
    lines = list(data)
    if not lines: return [',', []]
    if lines[0].startswith('\ufeff'): lines[0] = lines[0][1:]
    delimiter = ','
    if lines[0].startswith('sep='):
        value = lines.pop()[4:]
        if len(value) != 1 or value in '\r\n"': return None
        delimiter = value
    return [delimiter, [line.split(delimiter) for line in lines]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('custom', solve(_vary(['sep=;', '@;x'])), _vary([';', [['@', 'x']]]))
check('BOM directive', solve(_vary(['\ufeffsep=;', '@;x'])), _vary([';', [['@', 'x']]]))
check('default', solve(_vary(['@,x'])), _vary([',', [['@', 'x']]]))
check('later directive', solve(_vary(['a,b', 'sep=;'])), _vary([',', [['a', 'b'], ['sep=;']]]))
check('bad multi', solve(_vary(['sep=;;', 'x'])), _vary(None))
check('bad quote', solve(_vary(['sep="', 'x'])), _vary(None))
check('empty marker', solve(_vary(['sep=', 'x'])), _vary(None))
check('directive only', solve(_vary(['sep=;'])), _vary([';', []]))
check('zero', solve(_vary([])), _vary([',', []]))
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
customNone[';', [['cell', 'x']]]Failed
BOM directiveNone[';', [['cell', 'x']]]Failed
default[',', [['cell', 'x']]][',', [['cell', 'x']]]Passed
later directive[',', [['a', 'b'], ['sep=;']]][',', [['a', 'b'], ['sep=;']]]Passed
bad multiNoneNonePassed
bad quoteNoneNonePassed
empty markerNoneNonePassed
directive only[';', []][';', []]Passed
zero[',', []][',', []]Passed

SHA-256 / 995a5be7a8401647d7ae555ded92e5264bb160dddd5f3b1343f45dfd0d606adc

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):
    lines = list(data)
    if not lines: return [',', []]
    if lines[0].startswith('\ufeff'): lines[0] = lines[0][1:]
    delimiter = ','
    if lines[0].startswith('sep='):
        value = lines.pop(0)[4:]
        if len(value) != 1 or value in '\r\n"': return None
        delimiter = value
    return [delimiter, [line.split(delimiter) for line in lines]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('custom', solve(_vary(['sep=;', '@;x'])), _vary([';', [['@', 'x']]]))
check('BOM directive', solve(_vary(['\ufeffsep=;', '@;x'])), _vary([';', [['@', 'x']]]))
check('default', solve(_vary(['@,x'])), _vary([',', [['@', 'x']]]))
check('later directive', solve(_vary(['a,b', 'sep=;'])), _vary([',', [['a', 'b'], ['sep=;']]]))
check('bad multi', solve(_vary(['sep=;;', 'x'])), _vary(None))
check('bad quote', solve(_vary(['sep="', 'x'])), _vary(None))
check('empty marker', solve(_vary(['sep=', 'x'])), _vary(None))
check('directive only', solve(_vary(['sep=;'])), _vary([';', []]))
check('zero', solve(_vary([])), _vary([',', []]))
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
custom[';', [['cell', 'x']]][';', [['cell', 'x']]]Passed
BOM directive[';', [['cell', 'x']]][';', [['cell', 'x']]]Passed
default[',', [['cell', 'x']]][',', [['cell', 'x']]]Passed
later directive[',', [['a', 'b'], ['sep=;']]][',', [['a', 'b'], ['sep=;']]]Passed
bad multiNoneNonePassed
bad quoteNoneNonePassed
empty markerNoneNonePassed
directive only[';', []][';', []]Passed
zero[',', []][',', []]Passed

SHA-256 / 8fabc2b5931577e048a269d4a147f73b0a0137a2340e20dc50bf9d50bec13875

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

Case digest / 3a990ba9bd28bde5b6640b2d6dd8b974e7391dc08429c2b3673dcc7ab8ced93a