FAILURE MAP
← Case archive

FA-47426 / Delimited text / Open access

A cell line feed becomes an extra physical TSV record · 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

Embedded line feeds reach the record stream unescaped.

VERIFIED REPAIR

Preserve the named invariant at the faulty decision: field = field.replace('\n', '\\n')

Unsuccessful approach: Removing line feeds avoids extra records while losing the original value.

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.replace('\t', '\\t')
        field = field
        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 fixtureActualExpectedOutcome
all controlscell\t \r\\cell\t\n\r\\Failed
empty cells cell cell Passed
literal slash-t\\t\\tPassed
normalcell xcell xPassed
zero columnsPassed
all empty Passed
LF only \nFailed
CR only\r\rPassed

SHA-256 / b8fc3b8210d2fe0c4690477f04d3d8cf97d6fa51ec448029d05f47b81b1b2dd0

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', '\\t')
        field = field.replace('\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 fixtureActualExpectedOutcome
all controlscell\t\r\\cell\t\n\r\\Failed
empty cells cell cell Passed
literal slash-t\\t\\tPassed
normalcell xcell xPassed
zero columnsPassed
all empty Passed
LF only\nFailed
CR only\r\rPassed

SHA-256 / 2c1d9f0f221f3cf1dfdd8f83c4f6b13fd20e7b079a34e9b148c51749fd2e752d

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 fixtureActualExpectedOutcome
all controlscell\t\n\r\\cell\t\n\r\\Passed
empty cells cell cell Passed
literal slash-t\\t\\tPassed
normalcell xcell xPassed
zero columnsPassed
all empty Passed
LF only\n\nPassed
CR only\r\rPassed

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

Case digest / 4cf2e1060e9e8f00b7a4bf6db183fb59d561eddef1df9074a84dba0935a59395