FAILURE MAP
← Case archive

FA-47681 / Delimited text / Open access

Literal doubled-comment records are filtered as comments · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

The escaped-comment path drops a data record.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if line.startswith('##'): rows.append(line[1:].split('|'))

Unsuccessful approach: Stripping every marker decodes more than the one escape layer.

Case contract

Process already framed pipe records. Column-zero # starts a comment except ## encodes a literal leading # data record. A column-zero #!name=value directive sets a unique metadata name; malformed or duplicate directives reject. Other records, including leading-space # and empty records, are data. Return metadata and data rows.

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):
    meta, rows = {}, []
    for line in data:
        if line.startswith('##'): continue
        elif line.startswith('#!'):
            pair = line[2:].split('=', 1)
            if len(pair) != 2 or not pair[0]: return None
            key, value = pair
            if key in meta: return None
            meta[key] = value
        elif line.startswith('#'): continue
        else: rows.append(line.split('|'))
    return [meta, rows]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comments', solve(_vary(['# comment', '@|x'])), _vary([{}, [['@', 'x']]]))
check('escaped marker', solve(_vary(['##literal|@'])), _vary([{}, [['#literal', '@']]]))
check('space prefix', solve(_vary([' # data|@'])), _vary([{}, [[' # data', '@']]]))
check('metadata', solve(_vary(['#!unit=a=b', '@|x'])), _vary([{'unit': 'a=b'}, [['@', 'x']]]))
check('duplicate', solve(_vary(['#!x=1', '#!x=2'])), _vary(None))
check('bad directive', solve(_vary(['#!x'])), _vary(None))
check('empty name', solve(_vary(['#!=value'])), _vary(None))
check('empty data', solve(_vary([''])), _vary([{}, [['']]]))
check('marker chain', solve(_vary(['###data'])), _vary([{}, [['##data']]]))
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
comments[{}, [['cell', 'x']]][{}, [['cell', 'x']]]Passed
escaped marker[{}, []][{}, [['#literal', 'cell']]]Failed
space prefix[{}, [[' # data', 'cell']]][{}, [[' # data', 'cell']]]Passed
metadata[{'unit': 'a=b'}, [['cell', 'x']]][{'unit': 'a=b'}, [['cell', 'x']]]Passed
duplicateNoneNonePassed
bad directiveNoneNonePassed
empty nameNoneNonePassed
empty data[{}, [['']]][{}, [['']]]Passed
marker chain[{}, []][{}, [['##data']]]Failed
zero[{}, []][{}, []]Passed

SHA-256 / b7a11a8248b2ba8e3e081536494a3c5a09b8bc544a45142c0c0b5593c5fd24f8

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):
    meta, rows = {}, []
    for line in data:
        if line.startswith('##'): rows.append(line.lstrip('#').split('|'))
        elif line.startswith('#!'):
            pair = line[2:].split('=', 1)
            if len(pair) != 2 or not pair[0]: return None
            key, value = pair
            if key in meta: return None
            meta[key] = value
        elif line.startswith('#'): continue
        else: rows.append(line.split('|'))
    return [meta, rows]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comments', solve(_vary(['# comment', '@|x'])), _vary([{}, [['@', 'x']]]))
check('escaped marker', solve(_vary(['##literal|@'])), _vary([{}, [['#literal', '@']]]))
check('space prefix', solve(_vary([' # data|@'])), _vary([{}, [[' # data', '@']]]))
check('metadata', solve(_vary(['#!unit=a=b', '@|x'])), _vary([{'unit': 'a=b'}, [['@', 'x']]]))
check('duplicate', solve(_vary(['#!x=1', '#!x=2'])), _vary(None))
check('bad directive', solve(_vary(['#!x'])), _vary(None))
check('empty name', solve(_vary(['#!=value'])), _vary(None))
check('empty data', solve(_vary([''])), _vary([{}, [['']]]))
check('marker chain', solve(_vary(['###data'])), _vary([{}, [['##data']]]))
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
comments[{}, [['cell', 'x']]][{}, [['cell', 'x']]]Passed
escaped marker[{}, [['literal', 'cell']]][{}, [['#literal', 'cell']]]Failed
space prefix[{}, [[' # data', 'cell']]][{}, [[' # data', 'cell']]]Passed
metadata[{'unit': 'a=b'}, [['cell', 'x']]][{'unit': 'a=b'}, [['cell', 'x']]]Passed
duplicateNoneNonePassed
bad directiveNoneNonePassed
empty nameNoneNonePassed
empty data[{}, [['']]][{}, [['']]]Passed
marker chain[{}, [['data']]][{}, [['##data']]]Failed
zero[{}, []][{}, []]Passed

SHA-256 / a78aa9cc53036a8acf4fe6764cac757f6749f1f3c349ee5a7e5b89a98fff6c49

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):
    meta, rows = {}, []
    for line in data:
        if line.startswith('##'): rows.append(line[1:].split('|'))
        elif line.startswith('#!'):
            pair = line[2:].split('=', 1)
            if len(pair) != 2 or not pair[0]: return None
            key, value = pair
            if key in meta: return None
            meta[key] = value
        elif line.startswith('#'): continue
        else: rows.append(line.split('|'))
    return [meta, rows]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comments', solve(_vary(['# comment', '@|x'])), _vary([{}, [['@', 'x']]]))
check('escaped marker', solve(_vary(['##literal|@'])), _vary([{}, [['#literal', '@']]]))
check('space prefix', solve(_vary([' # data|@'])), _vary([{}, [[' # data', '@']]]))
check('metadata', solve(_vary(['#!unit=a=b', '@|x'])), _vary([{'unit': 'a=b'}, [['@', 'x']]]))
check('duplicate', solve(_vary(['#!x=1', '#!x=2'])), _vary(None))
check('bad directive', solve(_vary(['#!x'])), _vary(None))
check('empty name', solve(_vary(['#!=value'])), _vary(None))
check('empty data', solve(_vary([''])), _vary([{}, [['']]]))
check('marker chain', solve(_vary(['###data'])), _vary([{}, [['##data']]]))
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
comments[{}, [['cell', 'x']]][{}, [['cell', 'x']]]Passed
escaped marker[{}, [['#literal', 'cell']]][{}, [['#literal', 'cell']]]Passed
space prefix[{}, [[' # data', 'cell']]][{}, [[' # data', 'cell']]]Passed
metadata[{'unit': 'a=b'}, [['cell', 'x']]][{'unit': 'a=b'}, [['cell', 'x']]]Passed
duplicateNoneNonePassed
bad directiveNoneNonePassed
empty nameNoneNonePassed
empty data[{}, [['']]][{}, [['']]]Passed
marker chain[{}, [['##data']]][{}, [['##data']]]Passed
zero[{}, []][{}, []]Passed

SHA-256 / c949a9629cf94579fedf19126f589a3255cfeb34d192daea8ddd5ef4b54718b3

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

Case digest / a9fe96aae89fb98dfa2949e3c496c0335b05f4d9e1a45b917d3a9f3da5bdf4eb