FAILURE MAP
← Case archive

FA-48146 / Delimited text / Open access

A comment body is resumed as ordinary row text · case 01

A structured table violates the declared record or column contract.

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

ROOT CAUSE

A comment body is resumed as ordinary row text.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: elif ch == '#' and not quoted: break

Unsuccessful approach: The alternate implementation still violates the same declared invariant: a comment body is resumed as ordinary row text.

Case contract

Split a comma record with trailing comments. A # outside double quotes ends the record; inside quotes it is data. Quotes toggle quoted state and are removed; doubled quotes inside quotes emit one quote. Whitespace before a trailing comment is data. Unterminated quoting rejects.

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: i += 1; continue
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _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
comment['cell', 'xnote']['cell', 'x']Failed
quoted marker['#cell', 'x']['#cell', 'x']Passed
escaped quote['a"#b', 'z']['a"#b', 'z']Passed
spaces['cell x']['cell ']Failed
only comment['note']['']Failed
unclosedNoneNonePassed
normal['cell', 'x']['cell', 'x']Passed
comment commas['cellx', 'y']['cell']Failed

SHA-256 / 9fbdbdf3a3364d5ca511b2375a34da12bda55c41d89c360db865be28bc99a0b0

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: buf=[]
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _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
comment['cell', 'note']['cell', 'x']Failed
quoted marker['#cell', 'x']['#cell', 'x']Passed
escaped quote['a"#b', 'z']['a"#b', 'z']Passed
spaces['x']['cell ']Failed
only comment['note']['']Failed
unclosedNoneNonePassed
normal['cell', 'x']['cell', 'x']Passed
comment commas['x', 'y']['cell']Failed

SHA-256 / 1d4bdb26fbe97418ac0969bad33ca6c9d301937f022f7902e83b65d876194e48

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, buf, quoted, i = [], [], False, 0
    while i < len(data):
        ch=data[i]
        if ch == '"':
            if quoted and i+1 < len(data) and data[i+1] == '"':
                buf.append('"'); i += 2; continue
            quoted = not quoted
        elif ch == '#' and not quoted: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: return None
    out.append(''.join(buf))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('comment', solve(_vary('@,x#note')), _vary(['@', 'x']))
check('quoted marker', solve(_vary('"#@",x')), _vary(['#@', 'x']))
check('escaped quote', solve(_vary('"a""#b",z')), _vary(['a"#b', 'z']))
check('spaces', solve(_vary('@  #x')), _vary(['@  ']))
check('only comment', solve(_vary('#note')), _vary(['']))
check('unclosed', solve(_vary('"@#note')), _vary(None))
check('normal', solve(_vary('@,x')), _vary(['@', 'x']))
check('comment commas', solve(_vary('@#x,y')), _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
comment['cell', 'x']['cell', 'x']Passed
quoted marker['#cell', 'x']['#cell', 'x']Passed
escaped quote['a"#b', 'z']['a"#b', 'z']Passed
spaces['cell ']['cell ']Passed
only comment['']['']Passed
unclosedNoneNonePassed
normal['cell', 'x']['cell', 'x']Passed
comment commas['cell']['cell']Passed

SHA-256 / 015bbb11965f644930fe00f62300281bc9d252e6724a34460de3f6edbc924bcb

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

Case digest / 13d78cb827e43480fa886cb8d2fa12e8e9006f8ee7699d9cb177d3133c7a9b08