FAILURE MAP
← Case archive

FA-79376 / Barcode symbology encoding / Open access

UPC-E rule 3 keeps four manufacturer digits · case 01

Items whose code ends in 3 are looked up under the wrong product.

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

ROOT CAUSE

The d6 = 3 case uses the four-digit manufacturer layout of rule 4.

THE FAILURE

The d6 = 3 case uses the four-digit manufacturer layout of rule 4.

Unsuccessful approach: Swapping d4 and d5 keeps the length but reverses the product digits.

Case contract

Expand an 8-digit zero-suppressed UPC-E string (number system 0 or 1, six digits d1..d6, check digit passed through) into 12-digit UPC-A: d6 in 0-2 -> d1 d2 d6 0000 d3 d4 d5; d6 = 3 -> d1 d2 d3 00000 d4 d5; d6 = 4 -> d1 d2 d3 d4 00000 d5; d6 in 5-9 -> d1..d5 0000 d6. Invalid input returns None.

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(e):
    if len(e) != 8 or not all(ch in '0123456789' for ch in e):
        return None
    ns, d, chk = e[0], e[1:7], e[7]
    if ns not in ('0', '1'):
        return None
    last = d[5]
    if last in '012':
        body = d[0:2] + last + '0000' + d[2:5]
    elif last == '3':
        body = d[0:4] + '00000' + d[4]
    elif last == '4':
        body = d[0:4] + '00000' + d[4]
    else:
        body = d[0:5] + '0000' + last
    return ns + body + chk
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['01189536', '011800000956'], ['03046239', '030400000629'], ['25279409', None], ['04319958', '043199000058'], ['08023781', '080237000081'], ['16787022', '167200008702'], ['24955674', None], ['09341436', '093400000146']], [['00286336', '002800000636'], ['10930437', '109300000047'], ['00109039', '001000000909'], ['06482006', '064000008206'], ['13115485', '131154000085'], ['28046301', None], ['15524099', '155240000099'], ['07706936', '077000000696']], [['15918031', '159100000801'], ['04057239', '040500000729'], ['11882825', '118200008285'], ['21587198', None], ['07273910', '072100007390'], ['29592260', None], ['00838090', '008380000090'], ['01282734', '012800000274']], [['07065639', '070600000569'], ['03368937', '033600000897'], ['12867038', '128600000708'], ['08533799', '085337000099'], ['00787643', '007870000063'], ['08858661', '088586000061'], ['24707936', None], ['17766731', '177600000671']], [['00537830', '005300000780'], ['01585438', '015800000548'], ['08283998', '082839000098'], ['28773952', None], ['18771250', '187712000050'], ['13513558', '135135000058'], ['03833572', '038335000072'], ['02109436', '021000000946']]]
labels = ["regression: final digit 3 layout", "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: final digit 3 layout 0011890000056011800000956Failed
repair trap 1030460000029030400000629Failed
combined fault 2NoneNonePassed
control 3043199000058043199000058Passed
control 4080237000081080237000081Passed
boundary 5167200008702167200008702Passed
boundary 6NoneNonePassed
control 7093410000046093400000146Failed

SHA-256 / 83c3aa47c6993668514ea42d1fd4d4a08a55fd8742a617b940726342e6af74b4

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(e):
    if len(e) != 8 or not all(ch in '0123456789' for ch in e):
        return None
    ns, d, chk = e[0], e[1:7], e[7]
    if ns not in ('0', '1'):
        return None
    last = d[5]
    if last in '012':
        body = d[0:2] + last + '0000' + d[2:5]
    elif last == '3':
        body = d[0:3] + '00000' + d[4] + d[3]
    elif last == '4':
        body = d[0:4] + '00000' + d[4]
    else:
        body = d[0:5] + '0000' + last
    return ns + body + chk
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['01189536', '011800000956'], ['03046239', '030400000629'], ['25279409', None], ['04319958', '043199000058'], ['08023781', '080237000081'], ['16787022', '167200008702'], ['24955674', None], ['09341436', '093400000146']], [['00286336', '002800000636'], ['10930437', '109300000047'], ['00109039', '001000000909'], ['06482006', '064000008206'], ['13115485', '131154000085'], ['28046301', None], ['15524099', '155240000099'], ['07706936', '077000000696']], [['15918031', '159100000801'], ['04057239', '040500000729'], ['11882825', '118200008285'], ['21587198', None], ['07273910', '072100007390'], ['29592260', None], ['00838090', '008380000090'], ['01282734', '012800000274']], [['07065639', '070600000569'], ['03368937', '033600000897'], ['12867038', '128600000708'], ['08533799', '085337000099'], ['00787643', '007870000063'], ['08858661', '088586000061'], ['24707936', None], ['17766731', '177600000671']], [['00537830', '005300000780'], ['01585438', '015800000548'], ['08283998', '082839000098'], ['28773952', None], ['18771250', '187712000050'], ['13513558', '135135000058'], ['03833572', '038335000072'], ['02109436', '021000000946']]]
labels = ["regression: final digit 3 layout", "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: final digit 3 layout 0011800000596011800000956Failed
repair trap 1030400000269030400000629Failed
combined fault 2NoneNonePassed
control 3043199000058043199000058Passed
control 4080237000081080237000081Passed
boundary 5167200008702167200008702Passed
boundary 6NoneNonePassed
control 7093400000416093400000146Failed

SHA-256 / d53c74b77b8f3f5b241b18bf4631d76e2ac5194ade2bc993d10ce885253e1638

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 294d405760ce13c7ede2813240ebd854122721ff37063c02db246696b0f87470