FAILURE MAP
← Case archive

FA-3136 / Serialization / Open access

A quoted JSON string contains raw control characters · case 01

A quoted JSON string contains raw control characters.

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: Serialize a string as compact JSON with Unicode characters preserved.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Serialize a string as compact JSON with Unicode characters preserved.

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

Case contract

Serialize a string as compact JSON with Unicode characters preserved.

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 '"'+x+'"'
    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\nb'), '"a\\nb"')
check('boundary 2', solve('a"b'), '"a\\"b"')
check('boundary 3', solve('é'), '"é"')
check('boundary 4', solve(''), '""')
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""a\nb"Failed
boundary 2"a"b""a\"b"Failed
boundary 3"é""é"Passed
boundary 4""""Passed

SHA-256 / efedf265cb2eef9102897ebdbfaefc799a96e392e77286e64527733a4c4b3df0

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 '"'+x.replace('\\','\\\\').replace('"','\\"')+'"'
    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\nb'), '"a\\nb"')
check('boundary 2', solve('a"b'), '"a\\"b"')
check('boundary 3', solve('é'), '"é"')
check('boundary 4', solve(''), '""')
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""a\nb"Failed
boundary 2"a\"b""a\"b"Passed
boundary 3"é""é"Passed
boundary 4""""Passed

SHA-256 / 8c55395f432f2a718ee7294b4ffb2a1ceeb0e12ad03eeeceb6c4f2068408764d

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:
        return json.dumps(x,ensure_ascii=False)
    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\nb'), '"a\\nb"')
check('boundary 2', solve('a"b'), '"a\\"b"')
check('boundary 3', solve('é'), '"é"')
check('boundary 4', solve(''), '""')
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\nb""a\nb"Passed
boundary 2"a\"b""a\"b"Passed
boundary 3"é""é"Passed
boundary 4""""Passed

SHA-256 / 9127dbc272d0ee7541003be3d4c17c61511851a43e472b90434196e0b7d1c9f7

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

Case digest / 3e706cd4a94fdf2c0ab31d9adea25878b1039155f5687e1e2044bbdc0b76e845