FAILURE MAP
← Case archive

FA-181 / Protocols / Open access

A character count truncates a UTF-8 frame · case 01

The declared payload length is smaller than the actual UTF-8 payload for non-ASCII text.

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

ROOT CAUSE

A protocol byte count is calculated from Unicode characters rather than the encoded payload.

VERIFIED REPAIR

Encode once to UTF-8 and prefix the length of the encoded bytes.

Unsuccessful approach: Counting UTF-16 code units still does not measure UTF-8 payload bytes.

Case contract

Return the hexadecimal representation of an ASCII decimal byte-length prefix, a colon, then the UTF-8 payload. The prefix excludes its own bytes and the colon.

Why this case matters

Length-prefixed protocols operate on bytes. Unicode code points and UTF-16 units match byte counts for some fixtures, making ASCII-only tests insufficient.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(text):
    return (str(len(text)).encode('ascii') + b':' + text.encode('utf-8')).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ASCII length', solve('x' * N), (str(N).encode() + b':' + b'x' * N).hex())
check('two-byte code point', solve('é' * N), (str(2 * N).encode() + b':' + b'\xc3\xa9' * N).hex())
check('four-byte code point', solve('🙂' * N), (str(4 * N).encode() + b':' + b'\xf0\x9f\x99\x82' * N).hex())
check('combining mark remains separate', solve('e\u0301' * N), (str(3 * N).encode() + b':' + b'e\xcc\x81' * N).hex())
check('mixed encoding widths', solve('A界' * N), (str(4 * N).encode() + b':' + b'A\xe7\x95\x8c' * N).hex())
check('empty payload', solve(''), '303a')
check('delimiter inside payload', solve(':' * N), (str(N).encode() + b':' + b':' * N).hex())
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
ASCII length313a78313a78Passed
two-byte code point313ac3a9323ac3a9Failed
four-byte code point313af09f9982343af09f9982Failed
combining mark remains separate323a65cc81333a65cc81Failed
mixed encoding widths323a41e7958c343a41e7958cFailed
empty payload303a303aPassed
delimiter inside payload313a3a313a3aPassed

SHA-256 / 3ff8d5519ba47fb21760914b1684da866c42289365f73a6fdf0400396bd4e281

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(text):
    return (str(len(text.encode('utf-16-le')) // 2).encode('ascii') + b':' + text.encode('utf-8')).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ASCII length', solve('x' * N), (str(N).encode() + b':' + b'x' * N).hex())
check('two-byte code point', solve('é' * N), (str(2 * N).encode() + b':' + b'\xc3\xa9' * N).hex())
check('four-byte code point', solve('🙂' * N), (str(4 * N).encode() + b':' + b'\xf0\x9f\x99\x82' * N).hex())
check('combining mark remains separate', solve('e\u0301' * N), (str(3 * N).encode() + b':' + b'e\xcc\x81' * N).hex())
check('mixed encoding widths', solve('A界' * N), (str(4 * N).encode() + b':' + b'A\xe7\x95\x8c' * N).hex())
check('empty payload', solve(''), '303a')
check('delimiter inside payload', solve(':' * N), (str(N).encode() + b':' + b':' * N).hex())
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
ASCII length313a78313a78Passed
two-byte code point313ac3a9323ac3a9Failed
four-byte code point323af09f9982343af09f9982Failed
combining mark remains separate323a65cc81333a65cc81Failed
mixed encoding widths323a41e7958c343a41e7958cFailed
empty payload303a303aPassed
delimiter inside payload313a3a313a3aPassed

SHA-256 / 58a2a6a7bf0be2f0f74466ec4bda0a13e4d99c99fbe9d74c3703d9161bba1028

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(text):
    payload = text.encode('utf-8')
    return (str(len(payload)).encode('ascii') + b':' + payload).hex()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('ASCII length', solve('x' * N), (str(N).encode() + b':' + b'x' * N).hex())
check('two-byte code point', solve('é' * N), (str(2 * N).encode() + b':' + b'\xc3\xa9' * N).hex())
check('four-byte code point', solve('🙂' * N), (str(4 * N).encode() + b':' + b'\xf0\x9f\x99\x82' * N).hex())
check('combining mark remains separate', solve('e\u0301' * N), (str(3 * N).encode() + b':' + b'e\xcc\x81' * N).hex())
check('mixed encoding widths', solve('A界' * N), (str(4 * N).encode() + b':' + b'A\xe7\x95\x8c' * N).hex())
check('empty payload', solve(''), '303a')
check('delimiter inside payload', solve(':' * N), (str(N).encode() + b':' + b':' * N).hex())
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
ASCII length313a78313a78Passed
two-byte code point323ac3a9323ac3a9Passed
four-byte code point343af09f9982343af09f9982Passed
combining mark remains separate333a65cc81333a65cc81Passed
mixed encoding widths343a41e7958c343a41e7958cPassed
empty payload303a303aPassed
delimiter inside payload313a3a313a3aPassed

SHA-256 / d704e9c3120f56f4c8c7d56b3463be04bd16f47cc3a0149761f775f63f34e370

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

Case digest / f6b2f977625fa55b2bfc8cfcd3179516066be288bf6ba0661479d8b515ee6c14