FAILURE MAP
← Case archive

FA-72311 / Error-correcting codes / Open access

RS framing reports a full last codeword for an empty payload · case 01

An empty payload reports k data bytes in its last codeword.

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

ROOT CAUSE

The zero-codeword case falls through the general formula (payload - (0 - 1)*k).

VERIFIED REPAIR

Report 0 data bytes when there are no codewords.

Unsuccessful approach: Returning None for an empty payload treats a valid request as an error.

Case contract

Frame a payload of the given number of bytes into shortened RS(n, k) codewords: cw = ceil(payload / k) codewords, the last one carries payload - (cw - 1)*k data bytes (shortened, zero padding not transmitted), and each codeword adds n - k parity bytes. An empty payload uses no codewords. Return [cw, last data bytes, bytes sent]; invalid parameters return None.

Why this case matters

Link layers size FEC frames and transmit budgets from the payload length.

1 / The failure

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

N = 1
observations = []
def solve(payload, n, k):
    if payload < 0 or not 0 < k < n:
        return None
    cw = -(-payload // k)
    last = payload - (cw - 1) * k
    sent = payload + cw * (n - k)
    return [cw, last, sent]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [1, 255, 239]', [1, 255, 239], [1, 1, 17]], ['control [239, 255, 239]', [239, 255, 239], [1, 239, 255]], ['control [240, 255, 239]', [240, 255, 239], [2, 1, 272]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]], ['control [11, 15, 11]', [11, 15, 11], [1, 11, 15]], ['control [12, 15, 11]', [12, 15, 11], [2, 1, 20]], ['control [33, 15, 11]', [33, 15, 11], [3, 11, 45]], ['control [100, 204, 188]', [100, 204, 188], [1, 100, 116]], ['control [188, 204, 188]', [188, 204, 188], [1, 188, 204]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [100, 204, 188]', [100, 204, 188], [1, 100, 116]], ['control [188, 204, 188]', [188, 204, 188], [1, 188, 204]], ['control [376, 204, 188]', [376, 204, 188], [2, 188, 408]], ['control [-1, 15, 11]', [-1, 15, 11], None], ['control [5, 11, 11]', [5, 11, 11], None], ['control [22, 7, 4]', [22, 7, 4], [6, 2, 40]], ['control [1, 7, 4]', [1, 7, 4], [1, 1, 4]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [22, 7, 4]', [22, 7, 4], [6, 2, 40]], ['control [1, 7, 4]', [1, 7, 4], [1, 1, 4]], ['control [1, 255, 239]', [1, 255, 239], [1, 1, 17]], ['control [239, 255, 239]', [239, 255, 239], [1, 239, 255]], ['control [240, 255, 239]', [240, 255, 239], [2, 1, 272]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]], ['control [11, 15, 11]', [11, 15, 11], [1, 11, 15]], ['control [12, 15, 11]', [12, 15, 11], [2, 1, 20]], ['control [33, 15, 11]', [33, 15, 11], [3, 11, 45]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
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
regression [0, 255, 239][0, 239, 0][0, 0, 0]Failed
control [1, 255, 239][1, 1, 17][1, 1, 17]Passed
control [239, 255, 239][1, 239, 255][1, 239, 255]Passed
control [240, 255, 239][2, 1, 272][2, 1, 272]Passed
control [478, 255, 239][2, 239, 510][2, 239, 510]Passed
control [1000, 255, 223][5, 108, 1160][5, 108, 1160]Passed
control [223, 255, 223][1, 223, 255][1, 223, 255]Passed
control [5, 15, 11][1, 5, 9][1, 5, 9]Passed

SHA-256 / 7cf94c9042590656d81c9b51b5fe46a50f93641ab75542dea5648562f767e874

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(payload, n, k):
    if payload < 0 or not 0 < k < n:
        return None
    cw = -(-payload // k)
    last = payload - (cw - 1) * k if cw else None
    sent = payload + cw * (n - k)
    return [cw, last, sent]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [1, 255, 239]', [1, 255, 239], [1, 1, 17]], ['control [239, 255, 239]', [239, 255, 239], [1, 239, 255]], ['control [240, 255, 239]', [240, 255, 239], [2, 1, 272]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]], ['control [11, 15, 11]', [11, 15, 11], [1, 11, 15]], ['control [12, 15, 11]', [12, 15, 11], [2, 1, 20]], ['control [33, 15, 11]', [33, 15, 11], [3, 11, 45]], ['control [100, 204, 188]', [100, 204, 188], [1, 100, 116]], ['control [188, 204, 188]', [188, 204, 188], [1, 188, 204]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [100, 204, 188]', [100, 204, 188], [1, 100, 116]], ['control [188, 204, 188]', [188, 204, 188], [1, 188, 204]], ['control [376, 204, 188]', [376, 204, 188], [2, 188, 408]], ['control [-1, 15, 11]', [-1, 15, 11], None], ['control [5, 11, 11]', [5, 11, 11], None], ['control [22, 7, 4]', [22, 7, 4], [6, 2, 40]], ['control [1, 7, 4]', [1, 7, 4], [1, 1, 4]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [22, 7, 4]', [22, 7, 4], [6, 2, 40]], ['control [1, 7, 4]', [1, 7, 4], [1, 1, 4]], ['control [1, 255, 239]', [1, 255, 239], [1, 1, 17]], ['control [239, 255, 239]', [239, 255, 239], [1, 239, 255]], ['control [240, 255, 239]', [240, 255, 239], [2, 1, 272]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]], ['control [11, 15, 11]', [11, 15, 11], [1, 11, 15]], ['control [12, 15, 11]', [12, 15, 11], [2, 1, 20]], ['control [33, 15, 11]', [33, 15, 11], [3, 11, 45]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
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
regression [0, 255, 239][0, None, 0][0, 0, 0]Failed
control [1, 255, 239][1, 1, 17][1, 1, 17]Passed
control [239, 255, 239][1, 239, 255][1, 239, 255]Passed
control [240, 255, 239][2, 1, 272][2, 1, 272]Passed
control [478, 255, 239][2, 239, 510][2, 239, 510]Passed
control [1000, 255, 223][5, 108, 1160][5, 108, 1160]Passed
control [223, 255, 223][1, 223, 255][1, 223, 255]Passed
control [5, 15, 11][1, 5, 9][1, 5, 9]Passed

SHA-256 / 6f14882181cb436124e93e376f34026de3cc39780de3ea58b1f545160f7b53ba

3 / The verified repair

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

N = 1
observations = []
def solve(payload, n, k):
    if payload < 0 or not 0 < k < n:
        return None
    cw = -(-payload // k)
    last = payload - (cw - 1) * k if cw else 0
    sent = payload + cw * (n - k)
    return [cw, last, sent]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [1, 255, 239]', [1, 255, 239], [1, 1, 17]], ['control [239, 255, 239]', [239, 255, 239], [1, 239, 255]], ['control [240, 255, 239]', [240, 255, 239], [2, 1, 272]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]], ['control [11, 15, 11]', [11, 15, 11], [1, 11, 15]], ['control [12, 15, 11]', [12, 15, 11], [2, 1, 20]], ['control [33, 15, 11]', [33, 15, 11], [3, 11, 45]], ['control [100, 204, 188]', [100, 204, 188], [1, 100, 116]], ['control [188, 204, 188]', [188, 204, 188], [1, 188, 204]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [100, 204, 188]', [100, 204, 188], [1, 100, 116]], ['control [188, 204, 188]', [188, 204, 188], [1, 188, 204]], ['control [376, 204, 188]', [376, 204, 188], [2, 188, 408]], ['control [-1, 15, 11]', [-1, 15, 11], None], ['control [5, 11, 11]', [5, 11, 11], None], ['control [22, 7, 4]', [22, 7, 4], [6, 2, 40]], ['control [1, 7, 4]', [1, 7, 4], [1, 1, 4]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [22, 7, 4]', [22, 7, 4], [6, 2, 40]], ['control [1, 7, 4]', [1, 7, 4], [1, 1, 4]], ['control [1, 255, 239]', [1, 255, 239], [1, 1, 17]], ['control [239, 255, 239]', [239, 255, 239], [1, 239, 255]], ['control [240, 255, 239]', [240, 255, 239], [2, 1, 272]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]]], [['regression [0, 255, 239]', [0, 255, 239], [0, 0, 0]], ['control [478, 255, 239]', [478, 255, 239], [2, 239, 510]], ['control [1000, 255, 223]', [1000, 255, 223], [5, 108, 1160]], ['control [223, 255, 223]', [223, 255, 223], [1, 223, 255]], ['control [5, 15, 11]', [5, 15, 11], [1, 5, 9]], ['control [11, 15, 11]', [11, 15, 11], [1, 11, 15]], ['control [12, 15, 11]', [12, 15, 11], [2, 1, 20]], ['control [33, 15, 11]', [33, 15, 11], [3, 11, 45]]]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
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
regression [0, 255, 239][0, 0, 0][0, 0, 0]Passed
control [1, 255, 239][1, 1, 17][1, 1, 17]Passed
control [239, 255, 239][1, 239, 255][1, 239, 255]Passed
control [240, 255, 239][2, 1, 272][2, 1, 272]Passed
control [478, 255, 239][2, 239, 510][2, 239, 510]Passed
control [1000, 255, 223][5, 108, 1160][5, 108, 1160]Passed
control [223, 255, 223][1, 223, 255][1, 223, 255]Passed
control [5, 15, 11][1, 5, 9][1, 5, 9]Passed

SHA-256 / e159780d50db63a10b1059e3a6ee2f948773a88ed6d0ffc633462d74a3090bdc

Verification & scope

A deterministic, bounded teaching model of the named code under the stated contract; not a production codec. 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:48:37.319344+00:00.

Case digest / ad1b23da45e53c2cce356a89406a0c1f504006350a051bc20b5eed8dab85365c