FAILURE MAP
← Case archive

FA-79716 / Barcode symbology encoding / Open access

Byte alignment adds a whole zero byte to aligned data · case 01

Aligned payloads gain a spurious 0x00 codeword before the pad bytes.

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

ROOT CAUSE

The alignment adds 8 - len % 8 bits, which is 8 when already aligned.

VERIFIED REPAIR

Add (-len) mod 8 zero bits.

Unsuccessful approach: Adding len % 8 bits aligns only by coincidence.

Case contract

Finish a QR data bit stream for a symbol with `capacity` data codewords: data longer than capacity*8 bits returns None; append a terminator of up to four 0 bits (truncated if capacity is reached), pad with 0 bits to a byte boundary, split into codewords, then append pad codewords alternating 0xEC, 0x11 starting with 0xEC until the capacity is filled.

Why this case matters

Retail, logistics, pharmacy and document workflows depend on encoders that produce exactly the module pattern, code-set switches, separators and quiet zones scanners expect; one misplaced module or separator makes a label unreadable or, worse, scan as different data.

1 / The failure

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

N = 1
observations = []
def solve(bits, capacity):
    cap = capacity * 8
    if len(bits) > cap:
        return None
    bits += '0' * min(4, cap - len(bits))
    bits += '0' * (8 - len(bits) % 8)
    words = [int(bits[i:i + 8], 2) for i in range(0, len(bits), 8)]
    pads = [0xEC, 0x11]
    k = 0
    while len(words) < capacity:
        words.append(pads[k % 2])
        k += 1
    return words
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('11110', 1), [240]], [('11000111110010110000011101', 7), [199, 203, 7, 64, 236, 17, 236]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('001110011011101011101000', 4), [57, 186, 232, 0]], [('101011111101111010101001010011000', 4), None], [('001101110111100101001100111101010', 4), None], [('00001110010101111011010001101111', 6), [14, 87, 180, 111, 0, 236]], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]]], [[('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('1100010000000100010111100', 6), [196, 4, 94, 0, 236, 17]], [('1110011111000110', 7), [231, 198, 0, 236, 17, 236, 17]], [('00101010101111110010011110110010011100110', 5), None], [('1110111100000001110000101', 3), None], [('10110001001101011', 2), None], [('000010111001001111110001111000101', 4), None], [('000100', 1), [16]]], [[('10110101', 1), [181]], [('111111110110110111', 3), [255, 109, 192]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('', 3), [0, 236, 17]], [('10100010001101111', 2), None], [('111010111110010110000100101101100011001010010011111010111', 7), None], [('1110100000110001011011010010010', 4), [232, 49, 109, 36]]], [[('01110011101100110010100111000111100111011111110101101110', 7), [115, 179, 41, 199, 157, 253, 110]], [('1101011000', 2), [214, 0]], [('0001101010100101110100100000001001110111000110110', 6), None], [('01000011', 2), [67, 0]], [('10110010', 2), [178, 0]], [('10001101000010011', 2), None], [('1010100000100110011011001000111101000001101100001', 6), None], [('00011', 1), [24]]], [[('100100000001111010001', 3), [144, 30, 136]], [('0010010011000011011010100', 7), [36, 195, 106, 0, 236, 17, 236]], [('010001110011110110111010011110011100001110101010100001101', 7), None], [('000101100', 1), None], [('11001010', 5), [202, 0, 236, 17, 236]], [('100010101011001101000110110111110', 4), None], [('0100011110111010010001', 5), [71, 186, 68, 0, 236]], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]]]]
labels = ["regression: byte boundary padding", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), 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: byte boundary padding 0[240, 0][240]Failed
repair trap 1[199, 203, 7, 64, 236, 17, 236][199, 203, 7, 64, 236, 17, 236]Passed
combined fault 2[125, 91, 232, 0, 236][125, 91, 232, 0, 236]Passed
control 3[57, 186, 232, 0][57, 186, 232, 0]Passed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6[14, 87, 180, 111, 0, 236][14, 87, 180, 111, 0, 236]Passed
control 7[190, 19, 91, 118, 0][190, 19, 91, 118]Failed

SHA-256 / 4fd117b0f6de5c3d864e6fade66b3b288b2a572dbe6e324293797bb0048fb5ae

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(bits, capacity):
    cap = capacity * 8
    if len(bits) > cap:
        return None
    bits += '0' * min(4, cap - len(bits))
    bits += '0' * (len(bits) % 8)
    words = [int(bits[i:i + 8], 2) for i in range(0, len(bits), 8)]
    pads = [0xEC, 0x11]
    k = 0
    while len(words) < capacity:
        words.append(pads[k % 2])
        k += 1
    return words
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('11110', 1), [240]], [('11000111110010110000011101', 7), [199, 203, 7, 64, 236, 17, 236]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('001110011011101011101000', 4), [57, 186, 232, 0]], [('101011111101111010101001010011000', 4), None], [('001101110111100101001100111101010', 4), None], [('00001110010101111011010001101111', 6), [14, 87, 180, 111, 0, 236]], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]]], [[('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('1100010000000100010111100', 6), [196, 4, 94, 0, 236, 17]], [('1110011111000110', 7), [231, 198, 0, 236, 17, 236, 17]], [('00101010101111110010011110110010011100110', 5), None], [('1110111100000001110000101', 3), None], [('10110001001101011', 2), None], [('000010111001001111110001111000101', 4), None], [('000100', 1), [16]]], [[('10110101', 1), [181]], [('111111110110110111', 3), [255, 109, 192]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('', 3), [0, 236, 17]], [('10100010001101111', 2), None], [('111010111110010110000100101101100011001010010011111010111', 7), None], [('1110100000110001011011010010010', 4), [232, 49, 109, 36]]], [[('01110011101100110010100111000111100111011111110101101110', 7), [115, 179, 41, 199, 157, 253, 110]], [('1101011000', 2), [214, 0]], [('0001101010100101110100100000001001110111000110110', 6), None], [('01000011', 2), [67, 0]], [('10110010', 2), [178, 0]], [('10001101000010011', 2), None], [('1010100000100110011011001000111101000001101100001', 6), None], [('00011', 1), [24]]], [[('100100000001111010001', 3), [144, 30, 136]], [('0010010011000011011010100', 7), [36, 195, 106, 0, 236, 17, 236]], [('010001110011110110111010011110011100001110101010100001101', 7), None], [('000101100', 1), None], [('11001010', 5), [202, 0, 236, 17, 236]], [('100010101011001101000110110111110', 4), None], [('0100011110111010010001', 5), [71, 186, 68, 0, 236]], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]]]]
labels = ["regression: byte boundary padding", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), 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: byte boundary padding 0[240][240]Passed
repair trap 1[199, 203, 7, 64, 0, 236, 17][199, 203, 7, 64, 236, 17, 236]Failed
combined fault 2[125, 91, 232, 0, 236][125, 91, 232, 0, 236]Passed
control 3[57, 186, 232, 0][57, 186, 232, 0]Passed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6[14, 87, 180, 111, 0, 236][14, 87, 180, 111, 0, 236]Passed
control 7[190, 19, 91, 118][190, 19, 91, 118]Passed

SHA-256 / 8bea9b0b80ff39b6721af6850d738cee4ea9f5cfb0895cbd738779c6259376b1

3 / The verified repair

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

N = 1
observations = []
def solve(bits, capacity):
    cap = capacity * 8
    if len(bits) > cap:
        return None
    bits += '0' * min(4, cap - len(bits))
    bits += '0' * (-len(bits) % 8)
    words = [int(bits[i:i + 8], 2) for i in range(0, len(bits), 8)]
    pads = [0xEC, 0x11]
    k = 0
    while len(words) < capacity:
        words.append(pads[k % 2])
        k += 1
    return words
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[('11110', 1), [240]], [('11000111110010110000011101', 7), [199, 203, 7, 64, 236, 17, 236]], [('011111010101101111101000', 5), [125, 91, 232, 0, 236]], [('001110011011101011101000', 4), [57, 186, 232, 0]], [('101011111101111010101001010011000', 4), None], [('001101110111100101001100111101010', 4), None], [('00001110010101111011010001101111', 6), [14, 87, 180, 111, 0, 236]], [('10111110000100110101101101110110', 4), [190, 19, 91, 118]]], [[('010111100111111111101011010111010101', 6), [94, 127, 235, 93, 80, 236]], [('1100010000000100010111100', 6), [196, 4, 94, 0, 236, 17]], [('1110011111000110', 7), [231, 198, 0, 236, 17, 236, 17]], [('00101010101111110010011110110010011100110', 5), None], [('1110111100000001110000101', 3), None], [('10110001001101011', 2), None], [('000010111001001111110001111000101', 4), None], [('000100', 1), [16]]], [[('10110101', 1), [181]], [('111111110110110111', 3), [255, 109, 192]], [('0110000101010010', 7), [97, 82, 0, 236, 17, 236, 17]], [('11010010000000100000001', 4), [210, 2, 2, 0]], [('', 3), [0, 236, 17]], [('10100010001101111', 2), None], [('111010111110010110000100101101100011001010010011111010111', 7), None], [('1110100000110001011011010010010', 4), [232, 49, 109, 36]]], [[('01110011101100110010100111000111100111011111110101101110', 7), [115, 179, 41, 199, 157, 253, 110]], [('1101011000', 2), [214, 0]], [('0001101010100101110100100000001001110111000110110', 6), None], [('01000011', 2), [67, 0]], [('10110010', 2), [178, 0]], [('10001101000010011', 2), None], [('1010100000100110011011001000111101000001101100001', 6), None], [('00011', 1), [24]]], [[('100100000001111010001', 3), [144, 30, 136]], [('0010010011000011011010100', 7), [36, 195, 106, 0, 236, 17, 236]], [('010001110011110110111010011110011100001110101010100001101', 7), None], [('000101100', 1), None], [('11001010', 5), [202, 0, 236, 17, 236]], [('100010101011001101000110110111110', 4), None], [('0100011110111010010001', 5), [71, 186, 68, 0, 236]], [('1001000010101110001111000110111010001110', 5), [144, 174, 60, 110, 142]]]]
labels = ["regression: byte boundary padding", "repair trap", "combined fault", "control", "control", "boundary", "boundary", "control"]
for i, (args, expected) in enumerate(fixtures[N-1]):
    check("%s %d" % (labels[i % len(labels)], i), 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: byte boundary padding 0[240][240]Passed
repair trap 1[199, 203, 7, 64, 236, 17, 236][199, 203, 7, 64, 236, 17, 236]Passed
combined fault 2[125, 91, 232, 0, 236][125, 91, 232, 0, 236]Passed
control 3[57, 186, 232, 0][57, 186, 232, 0]Passed
control 4NoneNonePassed
boundary 5NoneNonePassed
boundary 6[14, 87, 180, 111, 0, 236][14, 87, 180, 111, 0, 236]Passed
control 7[190, 19, 91, 118][190, 19, 91, 118]Passed

SHA-256 / b78eb524782a14e8c2ec2d8808d5d6a90807a769e622b4ed013b5305bb35adae

Verification & scope

A deterministic bounded teaching model with a stipulated contract; it makes no claim of conformance to any published specification. 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:49:47.026061+00:00.

Case digest / 155947efaf1291cfa1231202dd979bebd8c1dc335d3407f7fe773d8e0ef4c8aa