FAILURE MAP
← Case archive

FA-79391 / Barcode symbology encoding / Open access

UPC-E expansion accepts number systems other than 0 and 1 · case 01

Mistyped codes with a leading 2 are expanded to UPC-A instead of being rejected.

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

ROOT CAUSE

The number system digit is never restricted to the values UPC-E supports.

VERIFIED REPAIR

Reject any number system other than 0 or 1.

Unsuccessful approach: Allowing only 0 rejects valid number system 1 codes.

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 == '':
        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[3:5]
    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 = [[['25279409', None], ['28680954', None], ['04319958', '043199000058'], ['08023781', '080237000081'], ['01189536', '011800000956'], ['07573327', '075200007337'], ['09341436', '093400000146'], ['24955674', None]], [['27529098', None], ['28046301', None], ['20584835', None], ['06482006', '064000008206'], ['08877566', '088775000066'], ['03074477', '030744000077'], ['01759900', '017000005990'], ['26112800', None]], [['21922317', None], ['19115135', '191100000515'], ['20008097', None], ['00838090', '008380000090'], ['03132457', '031324000057'], ['06980800', '069000008080'], ['04080146', '040800000016'], ['29592260', None]], [['22375285', None], ['17766731', '177600000671'], ['21113550', None], ['00787643', '007870000063'], ['08858661', '088586000061'], ['09720132', '097200000012'], ['06596582', '065965000082'], ['26563639', None]], [['21443122', None], ['13513558', '135135000058'], ['21834264', None], ['03833572', '038335000072'], ['06185620', '061200008560'], ['02180640', '021800000060'], ['01092108', '010000009218'], ['22394703', None]]]
labels = ["regression: number system restriction", "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: number system restriction 0252000007949NoneFailed
repair trap 1286809000054NoneFailed
combined fault 2043199000058043199000058Passed
control 3080237000081080237000081Passed
control 4011800000956011800000956Passed
boundary 5075200007337075200007337Passed
boundary 6093400000146093400000146Passed
control 7249556000074NoneFailed

SHA-256 / 1b9c4806711f93b5cc37af3835673fbdb112c90d37084b7d5fbf9a81d30423c3

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 == '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[3:5]
    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 = [[['25279409', None], ['28680954', None], ['04319958', '043199000058'], ['08023781', '080237000081'], ['01189536', '011800000956'], ['07573327', '075200007337'], ['09341436', '093400000146'], ['24955674', None]], [['27529098', None], ['28046301', None], ['20584835', None], ['06482006', '064000008206'], ['08877566', '088775000066'], ['03074477', '030744000077'], ['01759900', '017000005990'], ['26112800', None]], [['21922317', None], ['19115135', '191100000515'], ['20008097', None], ['00838090', '008380000090'], ['03132457', '031324000057'], ['06980800', '069000008080'], ['04080146', '040800000016'], ['29592260', None]], [['22375285', None], ['17766731', '177600000671'], ['21113550', None], ['00787643', '007870000063'], ['08858661', '088586000061'], ['09720132', '097200000012'], ['06596582', '065965000082'], ['26563639', None]], [['21443122', None], ['13513558', '135135000058'], ['21834264', None], ['03833572', '038335000072'], ['06185620', '061200008560'], ['02180640', '021800000060'], ['01092108', '010000009218'], ['22394703', None]]]
labels = ["regression: number system restriction", "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: number system restriction 0252000007949NoneFailed
repair trap 1286809000054NoneFailed
combined fault 2043199000058043199000058Passed
control 3080237000081080237000081Passed
control 4011800000956011800000956Passed
boundary 5075200007337075200007337Passed
boundary 6093400000146093400000146Passed
control 7249556000074NoneFailed

SHA-256 / ee415e1f63bf374569da38eaf2818f3eee6c3f119d71afdace3fd289114c5a20

3 / The verified repair

Exit 0
"""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[3:5]
    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 = [[['25279409', None], ['28680954', None], ['04319958', '043199000058'], ['08023781', '080237000081'], ['01189536', '011800000956'], ['07573327', '075200007337'], ['09341436', '093400000146'], ['24955674', None]], [['27529098', None], ['28046301', None], ['20584835', None], ['06482006', '064000008206'], ['08877566', '088775000066'], ['03074477', '030744000077'], ['01759900', '017000005990'], ['26112800', None]], [['21922317', None], ['19115135', '191100000515'], ['20008097', None], ['00838090', '008380000090'], ['03132457', '031324000057'], ['06980800', '069000008080'], ['04080146', '040800000016'], ['29592260', None]], [['22375285', None], ['17766731', '177600000671'], ['21113550', None], ['00787643', '007870000063'], ['08858661', '088586000061'], ['09720132', '097200000012'], ['06596582', '065965000082'], ['26563639', None]], [['21443122', None], ['13513558', '135135000058'], ['21834264', None], ['03833572', '038335000072'], ['06185620', '061200008560'], ['02180640', '021800000060'], ['01092108', '010000009218'], ['22394703', None]]]
labels = ["regression: number system restriction", "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: number system restriction 0NoneNonePassed
repair trap 1NoneNonePassed
combined fault 2043199000058043199000058Passed
control 3080237000081080237000081Passed
control 4011800000956011800000956Passed
boundary 5075200007337075200007337Passed
boundary 6093400000146093400000146Passed
control 7NoneNonePassed

SHA-256 / eed2d1d8cf1ba7b8ddfe10eca0861bb794b6eac25c76b99f6c5e62a6060ee6bf

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

Case digest / 16908a5490984f94c7e04a0636647f3606bb6f5c6ab73a9f94d0949e75b9e4b5