FAILURE MAP
← Case archive

FA-79606 / Barcode symbology encoding / Open access

Plain Code 128 scans are parsed as GS1 · case 01

Internal Code 128 labels whose text happens to start with digits are interpreted as GTINs.

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

ROOT CAUSE

The identifier check accepts any Code 128 modifier, not just the FNC1-in-first-position ]C1.

VERIFIED REPAIR

Require exactly "]C1".

Unsuccessful approach: Accepting any identifier admits Data Matrix and QR prefixes.

Case contract

Parse scanner output of a GS1-128 symbol: it must start with the symbology identifier "]C1"; FNC1 separators arrive as GS (0x1D) and redundant separators are skipped. AIs are recognised by the shortest matching prefix among the predefined fixed-length AIs (00:18, 01/02:14, 11/13/15/17:6, 3103:6) and variable AIs (10/21 max 20, 30/37 max 8, 400 max 30). A fixed field must be complete and contain no GS; a variable field runs to the next GS or the end and must have 1..max characters. Return [[ai, value], ...] or an error.

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(s):
    fixed_len = {'00': 18, '01': 14, '02': 14, '11': 6, '13': 6, '15': 6, '17': 6, '3103': 6}
    var_max = {'10': 20, '21': 20, '30': 8, '37': 8, '400': 30}
    if not s.startswith(']C'):
        return {'error': 'not-gs1'}
    i = 3
    out = []
    while i < len(s):
        if s[i] == '\x1d':
            i += 1
            continue
        ai = None
        for L in (2, 3, 4):
            if s[i:i + L] in fixed_len or s[i:i + L] in var_max:
                ai = s[i:i + L]
                break
        if ai is None:
            return {'error': 'unknown-ai', 'at': i}
        i += len(ai)
        if ai in fixed_len:
            n = fixed_len[ai]
            val = s[i:i + n]
            if len(val) != n or '\x1d' in val:
                return {'error': 'short', 'ai': ai}
            i += n
        else:
            j = s.find('\x1d', i)
            if j == -1:
                j = len(s)
            val = s[i:j]
            if not 1 <= len(val) <= var_max[ai]:
                return {'error': 'length', 'ai': ai}
            i = j
        out.append([ai, val])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[']C011400783', {'error': 'not-gs1'}], [']C030638', {'error': 'not-gs1'}], [']C117140648306\x1d0141294680397442\x1d', [['17', '140648'], ['30', '6'], ['01', '41294680397442']]], [']C137244121375\x1d21\x1d400XAXCC9C/XXB/1\x1d10/CA', {'error': 'length', 'ai': '37'}], [']C1306\x1d21ABB1A-1/-C/91X', [['30', '6'], ['21', 'ABB1A-1/-C/91X']]], [']C111465510', [['11', '465510']]], [']C1101\x1d0148290236761503', [['10', '1'], ['01', '48290236761503']]], [']C03019\x1d10B9', {'error': 'not-gs1'}]], [[']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C000641730718185499091', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']C1310361473240011XBBC-1-CX1B-\x1d371255\x1d219X9B-C/', [['3103', '614732'], ['400', '11XBBC-1-CX1B-'], ['37', '1255'], ['21', '9X9B-C/']]], [']C117074388\x1d10ABCAA///BCA/B\x1d30850\x1d400CA1//9', [['17', '074388'], ['10', 'ABCAA///BCA/B'], ['30', '850'], ['400', 'CA1//9']]], [']C10174974523509559400CC-XAX/C1CX9A/CX19-\x1d0168571298055799', [['01', '74974523509559'], ['400', 'CC-XAX/C1CX9A/CX19-'], ['01', '68571298055799']]], [']C030072\x1d303326538', {'error': 'not-gs1'}]], [[']C0304', {'error': 'not-gs1'}], [']d2002942508545382808993103171446', {'error': 'not-gs1'}], [']C0\x1d2111/CBCX\x1d', {'error': 'not-gs1'}], [']C121-/1-X-9B\x1d17420369015026678280984317842704\x1d', [['21', '-/1-X-9B'], ['17', '420369'], ['01', '50266782809843'], ['17', '842704']]], [']C111990558117862\x1d10X-11\x1d0141668383672539', {'error': 'short', 'ai': '11'}], [']C117595764400A//-X1BCCBA9AX/-/99\x1d21CABB119BX1/19111XX\x1d3703\x1d', [['17', '595764'], ['400', 'A//-X1BCCBA9AX/-/99'], ['21', 'CABB119BX1/19111XX'], ['37', '03']]], [']C1006692098233759925', {'error': 'short', 'ai': '00'}], [']C0013259255554289421A1C9/9--C1\x1d0109002354118510B1B', {'error': 'not-gs1'}]], [[']C037882', {'error': 'not-gs1'}], [']C037551517779\x1d37107398', {'error': 'not-gs1'}], [']C0310304226611571884', {'error': 'not-gs1'}], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C1211CXX-B1B9XXX-/', [['21', '1CXX-B1B9XXX-/']]], [']C1308705431', [['30', '8705431']]], [']C1211\x1d37789365790\x1d30311652\x1d', {'error': 'length', 'ai': '37'}], [']C03103992498', {'error': 'not-gs1'}]], [[']C010XC99AA/AX1X/\x1d0190109573520425', {'error': 'not-gs1'}], [']C017335622\x1d10/A/1X9\x1d1019911-1X/1B1/C-B\x1d400AX/C', {'error': 'not-gs1'}], [']C0400A/CAB-BBBA9A/X/-X19/AA\x1d400-X9/B\x1d1132149611901187', {'error': 'not-gs1'}], [']C13722241627', [['37', '22241627']]], [']C137057\x1d3031\x1d01970394307005', {'error': 'short', 'ai': '01'}], [']C101984472204032109C1XAB\x1d3088946\x1d', {'error': 'unknown-ai', 'at': 19}], [']C121-X-BCCC/AB/11/XX-C-B1A\x1d310310809321XX9-CB/X/XAB1XXC', {'error': 'length', 'ai': '21'}], [']C037218164131\x1d017878870121363103882288', {'error': 'not-gs1'}]]]
labels = ["regression: symbology identifier check", "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: symbology identifier check 0[['11', '400783']]{'error': 'not-gs1'}Failed
repair trap 1[['30', '638']]{'error': 'not-gs1'}Failed
combined fault 2[['17', '140648'], ['30', '6'], ['01', '41294680397442']][['17', '140648'], ['30', '6'], ['01', '41294680397442']]Passed
control 3{'ai': '37', 'error': 'length'}{'ai': '37', 'error': 'length'}Passed
control 4[['30', '6'], ['21', 'ABB1A-1/-C/91X']][['30', '6'], ['21', 'ABB1A-1/-C/91X']]Passed
boundary 5[['11', '465510']][['11', '465510']]Passed
boundary 6[['10', '1'], ['01', '48290236761503']][['10', '1'], ['01', '48290236761503']]Passed
control 7[['30', '19'], ['10', 'B9']]{'error': 'not-gs1'}Failed

SHA-256 / 74e4159bbe822245f60b1f8357b03985052005ade2d8082106f7b98aff3a5803

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(s):
    fixed_len = {'00': 18, '01': 14, '02': 14, '11': 6, '13': 6, '15': 6, '17': 6, '3103': 6}
    var_max = {'10': 20, '21': 20, '30': 8, '37': 8, '400': 30}
    if not s.startswith(']'):
        return {'error': 'not-gs1'}
    i = 3
    out = []
    while i < len(s):
        if s[i] == '\x1d':
            i += 1
            continue
        ai = None
        for L in (2, 3, 4):
            if s[i:i + L] in fixed_len or s[i:i + L] in var_max:
                ai = s[i:i + L]
                break
        if ai is None:
            return {'error': 'unknown-ai', 'at': i}
        i += len(ai)
        if ai in fixed_len:
            n = fixed_len[ai]
            val = s[i:i + n]
            if len(val) != n or '\x1d' in val:
                return {'error': 'short', 'ai': ai}
            i += n
        else:
            j = s.find('\x1d', i)
            if j == -1:
                j = len(s)
            val = s[i:j]
            if not 1 <= len(val) <= var_max[ai]:
                return {'error': 'length', 'ai': ai}
            i = j
        out.append([ai, val])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[']C011400783', {'error': 'not-gs1'}], [']C030638', {'error': 'not-gs1'}], [']C117140648306\x1d0141294680397442\x1d', [['17', '140648'], ['30', '6'], ['01', '41294680397442']]], [']C137244121375\x1d21\x1d400XAXCC9C/XXB/1\x1d10/CA', {'error': 'length', 'ai': '37'}], [']C1306\x1d21ABB1A-1/-C/91X', [['30', '6'], ['21', 'ABB1A-1/-C/91X']]], [']C111465510', [['11', '465510']]], [']C1101\x1d0148290236761503', [['10', '1'], ['01', '48290236761503']]], [']C03019\x1d10B9', {'error': 'not-gs1'}]], [[']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C000641730718185499091', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']C1310361473240011XBBC-1-CX1B-\x1d371255\x1d219X9B-C/', [['3103', '614732'], ['400', '11XBBC-1-CX1B-'], ['37', '1255'], ['21', '9X9B-C/']]], [']C117074388\x1d10ABCAA///BCA/B\x1d30850\x1d400CA1//9', [['17', '074388'], ['10', 'ABCAA///BCA/B'], ['30', '850'], ['400', 'CA1//9']]], [']C10174974523509559400CC-XAX/C1CX9A/CX19-\x1d0168571298055799', [['01', '74974523509559'], ['400', 'CC-XAX/C1CX9A/CX19-'], ['01', '68571298055799']]], [']C030072\x1d303326538', {'error': 'not-gs1'}]], [[']C0304', {'error': 'not-gs1'}], [']d2002942508545382808993103171446', {'error': 'not-gs1'}], [']C0\x1d2111/CBCX\x1d', {'error': 'not-gs1'}], [']C121-/1-X-9B\x1d17420369015026678280984317842704\x1d', [['21', '-/1-X-9B'], ['17', '420369'], ['01', '50266782809843'], ['17', '842704']]], [']C111990558117862\x1d10X-11\x1d0141668383672539', {'error': 'short', 'ai': '11'}], [']C117595764400A//-X1BCCBA9AX/-/99\x1d21CABB119BX1/19111XX\x1d3703\x1d', [['17', '595764'], ['400', 'A//-X1BCCBA9AX/-/99'], ['21', 'CABB119BX1/19111XX'], ['37', '03']]], [']C1006692098233759925', {'error': 'short', 'ai': '00'}], [']C0013259255554289421A1C9/9--C1\x1d0109002354118510B1B', {'error': 'not-gs1'}]], [[']C037882', {'error': 'not-gs1'}], [']C037551517779\x1d37107398', {'error': 'not-gs1'}], [']C0310304226611571884', {'error': 'not-gs1'}], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C1211CXX-B1B9XXX-/', [['21', '1CXX-B1B9XXX-/']]], [']C1308705431', [['30', '8705431']]], [']C1211\x1d37789365790\x1d30311652\x1d', {'error': 'length', 'ai': '37'}], [']C03103992498', {'error': 'not-gs1'}]], [[']C010XC99AA/AX1X/\x1d0190109573520425', {'error': 'not-gs1'}], [']C017335622\x1d10/A/1X9\x1d1019911-1X/1B1/C-B\x1d400AX/C', {'error': 'not-gs1'}], [']C0400A/CAB-BBBA9A/X/-X19/AA\x1d400-X9/B\x1d1132149611901187', {'error': 'not-gs1'}], [']C13722241627', [['37', '22241627']]], [']C137057\x1d3031\x1d01970394307005', {'error': 'short', 'ai': '01'}], [']C101984472204032109C1XAB\x1d3088946\x1d', {'error': 'unknown-ai', 'at': 19}], [']C121-X-BCCC/AB/11/XX-C-B1A\x1d310310809321XX9-CB/X/XAB1XXC', {'error': 'length', 'ai': '21'}], [']C037218164131\x1d017878870121363103882288', {'error': 'not-gs1'}]]]
labels = ["regression: symbology identifier check", "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: symbology identifier check 0[['11', '400783']]{'error': 'not-gs1'}Failed
repair trap 1[['30', '638']]{'error': 'not-gs1'}Failed
combined fault 2[['17', '140648'], ['30', '6'], ['01', '41294680397442']][['17', '140648'], ['30', '6'], ['01', '41294680397442']]Passed
control 3{'ai': '37', 'error': 'length'}{'ai': '37', 'error': 'length'}Passed
control 4[['30', '6'], ['21', 'ABB1A-1/-C/91X']][['30', '6'], ['21', 'ABB1A-1/-C/91X']]Passed
boundary 5[['11', '465510']][['11', '465510']]Passed
boundary 6[['10', '1'], ['01', '48290236761503']][['10', '1'], ['01', '48290236761503']]Passed
control 7[['30', '19'], ['10', 'B9']]{'error': 'not-gs1'}Failed

SHA-256 / c49463dd6ef003883dcf21cb2371af10ae829957a3818313d6aab73d36eeb2dd

3 / The verified repair

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

N = 1
observations = []
def solve(s):
    fixed_len = {'00': 18, '01': 14, '02': 14, '11': 6, '13': 6, '15': 6, '17': 6, '3103': 6}
    var_max = {'10': 20, '21': 20, '30': 8, '37': 8, '400': 30}
    if not s.startswith(']C1'):
        return {'error': 'not-gs1'}
    i = 3
    out = []
    while i < len(s):
        if s[i] == '\x1d':
            i += 1
            continue
        ai = None
        for L in (2, 3, 4):
            if s[i:i + L] in fixed_len or s[i:i + L] in var_max:
                ai = s[i:i + L]
                break
        if ai is None:
            return {'error': 'unknown-ai', 'at': i}
        i += len(ai)
        if ai in fixed_len:
            n = fixed_len[ai]
            val = s[i:i + n]
            if len(val) != n or '\x1d' in val:
                return {'error': 'short', 'ai': ai}
            i += n
        else:
            j = s.find('\x1d', i)
            if j == -1:
                j = len(s)
            val = s[i:j]
            if not 1 <= len(val) <= var_max[ai]:
                return {'error': 'length', 'ai': ai}
            i = j
        out.append([ai, val])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[[']C011400783', {'error': 'not-gs1'}], [']C030638', {'error': 'not-gs1'}], [']C117140648306\x1d0141294680397442\x1d', [['17', '140648'], ['30', '6'], ['01', '41294680397442']]], [']C137244121375\x1d21\x1d400XAXCC9C/XXB/1\x1d10/CA', {'error': 'length', 'ai': '37'}], [']C1306\x1d21ABB1A-1/-C/91X', [['30', '6'], ['21', 'ABB1A-1/-C/91X']]], [']C111465510', [['11', '465510']]], [']C1101\x1d0148290236761503', [['10', '1'], ['01', '48290236761503']]], [']C03019\x1d10B9', {'error': 'not-gs1'}]], [[']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C000641730718185499091', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']C1310361473240011XBBC-1-CX1B-\x1d371255\x1d219X9B-C/', [['3103', '614732'], ['400', '11XBBC-1-CX1B-'], ['37', '1255'], ['21', '9X9B-C/']]], [']C117074388\x1d10ABCAA///BCA/B\x1d30850\x1d400CA1//9', [['17', '074388'], ['10', 'ABCAA///BCA/B'], ['30', '850'], ['400', 'CA1//9']]], [']C10174974523509559400CC-XAX/C1CX9A/CX19-\x1d0168571298055799', [['01', '74974523509559'], ['400', 'CC-XAX/C1CX9A/CX19-'], ['01', '68571298055799']]], [']C030072\x1d303326538', {'error': 'not-gs1'}]], [[']C0304', {'error': 'not-gs1'}], [']d2002942508545382808993103171446', {'error': 'not-gs1'}], [']C0\x1d2111/CBCX\x1d', {'error': 'not-gs1'}], [']C121-/1-X-9B\x1d17420369015026678280984317842704\x1d', [['21', '-/1-X-9B'], ['17', '420369'], ['01', '50266782809843'], ['17', '842704']]], [']C111990558117862\x1d10X-11\x1d0141668383672539', {'error': 'short', 'ai': '11'}], [']C117595764400A//-X1BCCBA9AX/-/99\x1d21CABB119BX1/19111XX\x1d3703\x1d', [['17', '595764'], ['400', 'A//-X1BCCBA9AX/-/99'], ['21', 'CABB119BX1/19111XX'], ['37', '03']]], [']C1006692098233759925', {'error': 'short', 'ai': '00'}], [']C0013259255554289421A1C9/9--C1\x1d0109002354118510B1B', {'error': 'not-gs1'}]], [[']C037882', {'error': 'not-gs1'}], [']C037551517779\x1d37107398', {'error': 'not-gs1'}], [']C0310304226611571884', {'error': 'not-gs1'}], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C1211CXX-B1B9XXX-/', [['21', '1CXX-B1B9XXX-/']]], [']C1308705431', [['30', '8705431']]], [']C1211\x1d37789365790\x1d30311652\x1d', {'error': 'length', 'ai': '37'}], [']C03103992498', {'error': 'not-gs1'}]], [[']C010XC99AA/AX1X/\x1d0190109573520425', {'error': 'not-gs1'}], [']C017335622\x1d10/A/1X9\x1d1019911-1X/1B1/C-B\x1d400AX/C', {'error': 'not-gs1'}], [']C0400A/CAB-BBBA9A/X/-X19/AA\x1d400-X9/B\x1d1132149611901187', {'error': 'not-gs1'}], [']C13722241627', [['37', '22241627']]], [']C137057\x1d3031\x1d01970394307005', {'error': 'short', 'ai': '01'}], [']C101984472204032109C1XAB\x1d3088946\x1d', {'error': 'unknown-ai', 'at': 19}], [']C121-X-BCCC/AB/11/XX-C-B1A\x1d310310809321XX9-CB/X/XAB1XXC', {'error': 'length', 'ai': '21'}], [']C037218164131\x1d017878870121363103882288', {'error': 'not-gs1'}]]]
labels = ["regression: symbology identifier check", "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: symbology identifier check 0{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
repair trap 1{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
combined fault 2[['17', '140648'], ['30', '6'], ['01', '41294680397442']][['17', '140648'], ['30', '6'], ['01', '41294680397442']]Passed
control 3{'ai': '37', 'error': 'length'}{'ai': '37', 'error': 'length'}Passed
control 4[['30', '6'], ['21', 'ABB1A-1/-C/91X']][['30', '6'], ['21', 'ABB1A-1/-C/91X']]Passed
boundary 5[['11', '465510']][['11', '465510']]Passed
boundary 6[['10', '1'], ['01', '48290236761503']][['10', '1'], ['01', '48290236761503']]Passed
control 7{'error': 'not-gs1'}{'error': 'not-gs1'}Passed

SHA-256 / c2935db76cfc61ee45e3233b32b14e48598e6de07691435abd23a49271813d99

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

Case digest / 6ef772f9b71bffe5f2ff430472c98c07a75156acad30b5a8e16cbc1885928e05