FA-47421 / Delimited text / Open access
A cell tab becomes an extra TSV column · case 01
A structured table violates the declared record or column contract.
ROOT CAUSE
The writer emits cell tabs as structural delimiters.
VERIFIED REPAIR
Preserve the named invariant at the faulty decision: field = field.replace('\t', '\\t')
Unsuccessful approach: Replacing tabs with spaces stops splitting but destroys cell content.
Case contract
Encode a list of text cells as TSV without a terminator. Escape backslashes before introducing backslash-t, backslash-n, backslash-r; preserve empty columns and all other text.
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 field in data:
field = field.replace('\\', '\\\\')
field = field
field = field.replace('\n', '\\n')
field = field.replace('\r', '\\r')
out.append(field)
return '\t'.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('all controls', solve(_vary(['@\t\n\r\\'])), _vary('@\\t\\n\\r\\\\'))
check('empty cells', solve(_vary(['', '@', ''])), _vary('\t@\t'))
check('literal slash-t', solve(_vary(['\\t'])), _vary('\\\\t'))
check('normal', solve(_vary(['@', 'x'])), _vary('@\tx'))
check('zero columns', solve(_vary([])), _vary(''))
check('all empty', solve(_vary(['', '', ''])), _vary('\t\t'))
check('LF only', solve(_vary(['\n'])), _vary('\\n'))
check('CR only', solve(_vary(['\r'])), _vary('\\r'))
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 |
|---|---|---|---|
| all controls | cell \n\r\\ | cell\t\n\r\\ | Failed |
| empty cells | cell | cell | Passed |
| literal slash-t | \\t | \\t | Passed |
| normal | cell x | cell x | Passed |
| zero columns | | | Passed |
| all empty | | | Passed |
| LF only | \n | \n | Passed |
| CR only | \r | \r | Passed |
SHA-256 / 3f433f7ed289e9ea08de2a58e5386b26b12d64e5247e272dd731681fcdd80281
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 field in data:
field = field.replace('\\', '\\\\')
field = field.replace('\t', ' ')
field = field.replace('\n', '\\n')
field = field.replace('\r', '\\r')
out.append(field)
return '\t'.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('all controls', solve(_vary(['@\t\n\r\\'])), _vary('@\\t\\n\\r\\\\'))
check('empty cells', solve(_vary(['', '@', ''])), _vary('\t@\t'))
check('literal slash-t', solve(_vary(['\\t'])), _vary('\\\\t'))
check('normal', solve(_vary(['@', 'x'])), _vary('@\tx'))
check('zero columns', solve(_vary([])), _vary(''))
check('all empty', solve(_vary(['', '', ''])), _vary('\t\t'))
check('LF only', solve(_vary(['\n'])), _vary('\\n'))
check('CR only', solve(_vary(['\r'])), _vary('\\r'))
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 |
|---|---|---|---|
| all controls | cell \n\r\\ | cell\t\n\r\\ | Failed |
| empty cells | cell | cell | Passed |
| literal slash-t | \\t | \\t | Passed |
| normal | cell x | cell x | Passed |
| zero columns | | | Passed |
| all empty | | | Passed |
| LF only | \n | \n | Passed |
| CR only | \r | \r | Passed |
SHA-256 / 915536738f9e3e41da26f13b21edb07fdcaa1625356d625643cf9a9edc017b7f
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 field in data:
field = field.replace('\\', '\\\\')
field = field.replace('\t', '\\t')
field = field.replace('\n', '\\n')
field = field.replace('\r', '\\r')
out.append(field)
return '\t'.join(out)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('all controls', solve(_vary(['@\t\n\r\\'])), _vary('@\\t\\n\\r\\\\'))
check('empty cells', solve(_vary(['', '@', ''])), _vary('\t@\t'))
check('literal slash-t', solve(_vary(['\\t'])), _vary('\\\\t'))
check('normal', solve(_vary(['@', 'x'])), _vary('@\tx'))
check('zero columns', solve(_vary([])), _vary(''))
check('all empty', solve(_vary(['', '', ''])), _vary('\t\t'))
check('LF only', solve(_vary(['\n'])), _vary('\\n'))
check('CR only', solve(_vary(['\r'])), _vary('\\r'))
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 |
|---|---|---|---|
| all controls | cell\t\n\r\\ | cell\t\n\r\\ | Passed |
| empty cells | cell | cell | Passed |
| literal slash-t | \\t | \\t | Passed |
| normal | cell x | cell x | Passed |
| zero columns | | | Passed |
| all empty | | | Passed |
| LF only | \n | \n | Passed |
| CR only | \r | \r | Passed |
SHA-256 / cb59a0aeadc5359c537e056b45d1753eb2d79c66b37674bf20822e8768925ba6
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:41.363749+00:00.
Case digest / f437553a2f9d90b0f67474b40634f7a0a86b71776f4139600907212fe7fd80bb