FAILURE MAP
← Case archive

FA-48161 / Delimited text / Open access

An open quoted comment-looking field is accepted at EOF · 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

An open quoted comment-looking field is accepted at EOF.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: if quoted: return None

Unsuccessful approach: The alternate implementation still violates the same declared invariant: an open quoted comment-looking field is accepted at eof.

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: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted: quoted=False
    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
unclosed['cell#note']NoneFailed
normal['cell', 'x']['cell', 'x']Passed
comment commas['cell']['cell']Passed

SHA-256 / cf89db8b7bdfb0a0caed5027b5dae1ffec259e77497079cf8ce0ca2eebf42e03

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: break
        elif ch == ',' and not quoted:
            out.append(''.join(buf)); buf=[]
        else: buf.append(ch)
        i += 1
    if quoted and '#' not in data: 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
unclosed['cell#note']NoneFailed
normal['cell', 'x']['cell', 'x']Passed
comment commas['cell']['cell']Passed

SHA-256 / 14a23d2c2cf7c070f517089c10df29ba43fcc026752fe34a8dbbdd40161e9cda

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

Case digest / f0eebe23b32ce4a4e4d99bc075b747f67b90782e4c9fc8a12836bf4628d19331