FAILURE MAP
← Case archive

FA-3306 / Encodings / Open access

Base64 decoding silently ignores foreign characters · case 01

Base64 decoding silently ignores foreign 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: Decode canonical standard alphabet base64 with validation; invalid input returns None.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Decode canonical standard alphabet base64 with validation; invalid input returns None.

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

Case contract

Decode canonical standard alphabet base64 with validation; invalid input returns 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 list(base64.b64decode(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('Y Q=='), None)
check('boundary 2', solve('YQ==\n'), None)
check('boundary 3', solve('YQ=='), [97])
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[97]NoneFailed
boundary 2[97]NoneFailed
boundary 3[97][97]Passed
boundary 4[][]Passed

SHA-256 / 35dfa0ad7c9e1bea36dfd49daf2310bdbca045f753b67b44290ed8cbb9102f5f

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 list(base64.b64decode(x.replace(' ','').replace('\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('Y Q=='), None)
check('boundary 2', solve('YQ==\n'), None)
check('boundary 3', solve('YQ=='), [97])
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[97]NoneFailed
boundary 2[97]NoneFailed
boundary 3[97][97]Passed
boundary 4[][]Passed

SHA-256 / 2ef2f37c8002f3f267b6a15fc63828789322163efdac61cbd5252bd513319d0c

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 list(base64.b64decode(x,validate=True))
        except (ValueError,binascii.Error):
            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('Y Q=='), None)
check('boundary 2', solve('YQ==\n'), None)
check('boundary 3', solve('YQ=='), [97])
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 1NoneNonePassed
boundary 2NoneNonePassed
boundary 3[97][97]Passed
boundary 4[][]Passed

SHA-256 / 014622123e1bf1d581356729ba552196eb6b6036b37b47ed96e0d0affa4ae1b9

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

Case digest / 79295bdcbc98a5c2027a8a7b545bf337cc21317cfb49e06af3f0e19005f6b84b