FAILURE MAP
← Case archive

FA-3301 / Encodings / Open access

URL-safe base64 uses the standard alphabet · case 01

URL-safe base64 uses the standard alphabet.

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: Encode hex bytes to padded URL-safe base64 ASCII.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Encode hex bytes to padded URL-safe base64 ASCII.

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

Case contract

Encode hex bytes to padded URL-safe base64 ASCII.

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 base64.b64encode(bytes.fromhex(x)).decode()
    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('fbff'), '-_8=')
check('boundary 2', solve('ff'), '_w==')
check('boundary 3', solve('61'), 'YQ==')
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+/8=-_8=Failed
boundary 2/w==_w==Failed
boundary 3YQ==YQ==Passed
boundary 4Passed

SHA-256 / d1afa1bf4cee046f048ad7275fc0091f7d8722cd6a43460cfc351af07488c3f9

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 base64.b64encode(bytes.fromhex(x)).decode().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('fbff'), '-_8=')
check('boundary 2', solve('ff'), '_w==')
check('boundary 3', solve('61'), 'YQ==')
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-/8=-_8=Failed
boundary 2/w==_w==Failed
boundary 3YQ==YQ==Passed
boundary 4Passed

SHA-256 / 6ed2a965d68288ac584b77fe63630362308f0fb92f4a80d85d963458ab290be6

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 base64.urlsafe_b64encode(bytes.fromhex(x)).decode()
    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('fbff'), '-_8=')
check('boundary 2', solve('ff'), '_w==')
check('boundary 3', solve('61'), 'YQ==')
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-_8=-_8=Passed
boundary 2_w==_w==Passed
boundary 3YQ==YQ==Passed
boundary 4Passed

SHA-256 / 5b0eab118ebc9eae8cd3c93a7afcf465ecd5ae3ca55bb6bb96d2323cae53d6c8

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

Case digest / 53e5f5e28237032cd60fe37650fe2cd67fcd6e82b7591a5bca77d65a80c80b34