FAILURE MAP
← Case archive

FA-3166 / Serialization / Open access

A decoder accepts a second trailing JSON value · case 01

A decoder accepts a second trailing JSON value.

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: Accept exactly one complete JSON value surrounded by whitespace; malformed documents return None.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Accept exactly one complete JSON value surrounded by whitespace; malformed documents return None.

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

Case contract

Accept exactly one complete JSON value surrounded by whitespace; malformed documents return None.

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 json.JSONDecoder().raw_decode(x.lstrip())[0]
    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('1 2'), None)
check('boundary 2', solve('1\n2'), None)
check('boundary 3', solve('  [1] \n'), [1])
check('boundary 4', solve('0'), 0)
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 11NoneFailed
boundary 21NoneFailed
boundary 3[1][1]Passed
boundary 400Passed

SHA-256 / 356d011f131d1b5b3b99cc6c2a5235bc192ccf00542e1f76aedbc70bff219b38

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 json.JSONDecoder().raw_decode(x.strip().splitlines()[0])[0]
    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('1 2'), None)
check('boundary 2', solve('1\n2'), None)
check('boundary 3', solve('  [1] \n'), [1])
check('boundary 4', solve('0'), 0)
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 11NoneFailed
boundary 21NoneFailed
boundary 3[1][1]Passed
boundary 400Passed

SHA-256 / d29e72c7a0bb166027c00899b7a6d363de972d3a6de2f0247f1bf0ae26bd7e07

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:
        try:
            return json.loads(x)
        except ValueError:
            return None
    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('1 2'), None)
check('boundary 2', solve('1\n2'), None)
check('boundary 3', solve('  [1] \n'), [1])
check('boundary 4', solve('0'), 0)
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 1NoneNonePassed
boundary 2NoneNonePassed
boundary 3[1][1]Passed
boundary 400Passed

SHA-256 / ca93e3d8e4a17232558310391f7848e3cfb72e8c46fca3e3a1ed201a29d0d726

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

Case digest / 5d9e6d5aee55966da889058c069ea99c39e9d5fe6f4815cfb41f1ab48e1f180a