FAILURE MAP
← Case archive

FA-3196 / Delimited text / Open access

CSV writing forgets fields containing record separators · case 01

CSV writing forgets fields containing record separators.

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

ROOT CAUSE

The implementation applies an operation whose text or grammar semantics violate this contract: Write one minimal-quoted CSV row with CRLF terminator.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Write one minimal-quoted CSV row with CRLF terminator.

Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.

Case contract

Write one minimal-quoted CSV row with CRLF terminator.

Why this case matters

A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ','.join(x)+'\r\n'
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(['a,b', 'c']), '"a,b",c\r\n')
check('boundary 2', solve(['a\nb']), '"a\nb"\r\n')
check('boundary 3', solve(['a"b']), '"a""b"\r\n')
check('boundary 4', solve(['a', '']), 'a,\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 fixtureActualExpectedOutcome
boundary 1a,b,c "a,b",c Failed
boundary 2a b "a b" Failed
boundary 3a"b "a""b" Failed
boundary 4a, a, Passed

SHA-256 / 4d24971db5121a7d31367baec3f95d2c9d191174523eeb1f3a051d387ea1ca5f

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return ','.join('"'+v+'"' if ',' in v else v for v in x)+'\r\n'
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(['a,b', 'c']), '"a,b",c\r\n')
check('boundary 2', solve(['a\nb']), '"a\nb"\r\n')
check('boundary 3', solve(['a"b']), '"a""b"\r\n')
check('boundary 4', solve(['a', '']), 'a,\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 fixtureActualExpectedOutcome
boundary 1"a,b",c "a,b",c Passed
boundary 2a b "a b" Failed
boundary 3a"b "a""b" Failed
boundary 4a, a, Passed

SHA-256 / cece9153a1fd466db49cc4a96cf9a4f2f00f47af378d7647aba2c7f5d0b9c642

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        out=io.StringIO(newline='')
        csv.writer(out,lineterminator='\r\n').writerow(x)
        return out.getvalue()
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve(['a,b', 'c']), '"a,b",c\r\n')
check('boundary 2', solve(['a\nb']), '"a\nb"\r\n')
check('boundary 3', solve(['a"b']), '"a""b"\r\n')
check('boundary 4', solve(['a', '']), 'a,\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 fixtureActualExpectedOutcome
boundary 1"a,b",c "a,b",c Passed
boundary 2"a b" "a b" Passed
boundary 3"a""b" "a""b" Passed
boundary 4a, a, Passed

SHA-256 / ad03da5703158b17b02ab29b663cbf8c55f49a99e28d36bac5a9dd7f8ff38bfd

Verification & scope

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

Case digest / 30cd6c231fb1de48fbae589522f58ebe482fd988d4c1ca0f6c0f67d93e6192a8