FA-47656 / Delimited text / Open access
A leading comment marker makes a data row disappear · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
The writer fails to protect data that a downstream reader classifies as comments.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: or value.startswith('#')
Unsuccessful approach: Quoting only a lone marker misses longer comment-looking data.
Case contract
Emit typed table cells as one comma row ending CRLF. None is bare NULL; strings equal NULL or empty must be quoted. Booleans are bare true/false, integers bare decimal. Other strings are quoted if they contain comma, quote, newline, CR, leading/trailing space, or begin # (comment protection). Double embedded quotes. Preserve Unicode and cell order.
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 = []
for value in data:
if value is None: field = 'NULL'
elif isinstance(value, bool): field = 'true' if value else 'false'
elif isinstance(value, int): field = str(value)
else:
quote = value in ('NULL', '') or any(c in value for c in ',"\r\n') or value != value.strip(' ')
field = value.replace('"', '""')
if quote: field = '"' + field + '"'
out.append(field)
return ','.join(out) + '\r\n'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('typed', solve(_vary(['@', None, True, False, 12])), _vary('@,NULL,true,false,12\r\n'))
check('null string', solve(_vary(['NULL', ''])), _vary('"NULL",""\r\n'))
check('comment', solve(_vary(['#@'])), _vary('"#@"\r\n'))
check('spaces', solve(_vary([' @ ', 'x'])), _vary('" @ ",x\r\n'))
check('escape', solve(_vary(['a"b'])), _vary('"a""b"\r\n'))
check('crlf', solve(_vary(['x\r\ny'])), _vary('"x\r\ny"\r\n'))
check('normal', solve(_vary(['@', 'β'])), _vary('@,β\r\n'))
check('empty row', solve(_vary([])), _vary('\r\n'))
check('negative', solve(_vary([-12])), _vary('-12\r\n'))
check('single space', solve(_vary([' '])), _vary('" "\r\n'))
check('trailing space', solve(_vary(['@ '])), _vary('"@ "\r\n'))
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| typed | cell,NULL,true,false,12
| cell,NULL,true,false,12
| Passed |
| null string | "NULL",""
| "NULL",""
| Passed |
| comment | #cell
| "#cell"
| Failed |
| spaces | " cell ",x
| " cell ",x
| Passed |
| escape | "a""b"
| "a""b"
| Passed |
| crlf | "x
y"
| "x
y"
| Passed |
| normal | cell,β
| cell,β
| Passed |
| empty row |
|
| Passed |
| negative | -12
| -12
| Passed |
| single space | " "
| " "
| Passed |
| trailing space | "cell "
| "cell "
| Passed |
SHA-256 / d3aac86eadabc280a14c12a79e66d3454d8bc95e7e46bd3649430902c6f3c2e2
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 = []
for value in data:
if value is None: field = 'NULL'
elif isinstance(value, bool): field = 'true' if value else 'false'
elif isinstance(value, int): field = str(value)
else:
quote = value in ('NULL', '') or any(c in value for c in ',"\r\n') or value != value.strip(' ') or value == '#'
field = value.replace('"', '""')
if quote: field = '"' + field + '"'
out.append(field)
return ','.join(out) + '\r\n'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('typed', solve(_vary(['@', None, True, False, 12])), _vary('@,NULL,true,false,12\r\n'))
check('null string', solve(_vary(['NULL', ''])), _vary('"NULL",""\r\n'))
check('comment', solve(_vary(['#@'])), _vary('"#@"\r\n'))
check('spaces', solve(_vary([' @ ', 'x'])), _vary('" @ ",x\r\n'))
check('escape', solve(_vary(['a"b'])), _vary('"a""b"\r\n'))
check('crlf', solve(_vary(['x\r\ny'])), _vary('"x\r\ny"\r\n'))
check('normal', solve(_vary(['@', 'β'])), _vary('@,β\r\n'))
check('empty row', solve(_vary([])), _vary('\r\n'))
check('negative', solve(_vary([-12])), _vary('-12\r\n'))
check('single space', solve(_vary([' '])), _vary('" "\r\n'))
check('trailing space', solve(_vary(['@ '])), _vary('"@ "\r\n'))
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| typed | cell,NULL,true,false,12
| cell,NULL,true,false,12
| Passed |
| null string | "NULL",""
| "NULL",""
| Passed |
| comment | #cell
| "#cell"
| Failed |
| spaces | " cell ",x
| " cell ",x
| Passed |
| escape | "a""b"
| "a""b"
| Passed |
| crlf | "x
y"
| "x
y"
| Passed |
| normal | cell,β
| cell,β
| Passed |
| empty row |
|
| Passed |
| negative | -12
| -12
| Passed |
| single space | " "
| " "
| Passed |
| trailing space | "cell "
| "cell "
| Passed |
SHA-256 / fc96350a7861db29e3655e0939bfb4723e97c1a0c101c2093400f119cabbbf05
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 = []
for value in data:
if value is None: field = 'NULL'
elif isinstance(value, bool): field = 'true' if value else 'false'
elif isinstance(value, int): field = str(value)
else:
quote = value in ('NULL', '') or any(c in value for c in ',"\r\n') or value != value.strip(' ') or value.startswith('#')
field = value.replace('"', '""')
if quote: field = '"' + field + '"'
out.append(field)
return ','.join(out) + '\r\n'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('typed', solve(_vary(['@', None, True, False, 12])), _vary('@,NULL,true,false,12\r\n'))
check('null string', solve(_vary(['NULL', ''])), _vary('"NULL",""\r\n'))
check('comment', solve(_vary(['#@'])), _vary('"#@"\r\n'))
check('spaces', solve(_vary([' @ ', 'x'])), _vary('" @ ",x\r\n'))
check('escape', solve(_vary(['a"b'])), _vary('"a""b"\r\n'))
check('crlf', solve(_vary(['x\r\ny'])), _vary('"x\r\ny"\r\n'))
check('normal', solve(_vary(['@', 'β'])), _vary('@,β\r\n'))
check('empty row', solve(_vary([])), _vary('\r\n'))
check('negative', solve(_vary([-12])), _vary('-12\r\n'))
check('single space', solve(_vary([' '])), _vary('" "\r\n'))
check('trailing space', solve(_vary(['@ '])), _vary('"@ "\r\n'))
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| typed | cell,NULL,true,false,12
| cell,NULL,true,false,12
| Passed |
| null string | "NULL",""
| "NULL",""
| Passed |
| comment | "#cell"
| "#cell"
| Passed |
| spaces | " cell ",x
| " cell ",x
| Passed |
| escape | "a""b"
| "a""b"
| Passed |
| crlf | "x
y"
| "x
y"
| Passed |
| normal | cell,β
| cell,β
| Passed |
| empty row |
|
| Passed |
| negative | -12
| -12
| Passed |
| single space | " "
| " "
| Passed |
| trailing space | "cell "
| "cell "
| Passed |
SHA-256 / 01dab3c6df4f14a2de881e543fd7f557862fb045b3894b8344acc59adc9432de
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.577806+00:00.
Case digest / c84b70c8cad8d94d49ed5c5078218b14c6deb42acce6ba6bb988a4da5e8a3538