FAILURE MAP
← Case archive

FA-79631 / Barcode symbology encoding / Open access

Truncated GTIN at the end of a scan is accepted · case 01

A partially read symbol yields a 12-digit GTIN without error.

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

ROOT CAUSE

Only embedded separators are rejected; a short final fixed field passes.

VERIFIED REPAIR

Require exactly the predefined length.

Unsuccessful approach: Allowing one missing digit still accepts truncated values.

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(']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 '\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 = [[[']C13038307\x1d21B1CCBB9AAAX//\x1d1120858431033208', {'error': 'short', 'ai': '3103'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C011400783', {'error': 'not-gs1'}], [']C03019\x1d10B9', {'error': 'not-gs1'}], [']C117140648306\x1d0141294680397442\x1d', [['17', '140648'], ['30', '6'], ['01', '41294680397442']]], [']d221B-1BA9-B\x1d219X91//1X9-/1A-C\x1d10BBCB1-9/-/9//-/BC1-A-X\x1d21/ABXAX9C-CC/-\x1d', {'error': 'not-gs1'}], [']C0\x1d3028612956', {'error': 'not-gs1'}], [']C1\x1d01842115194162', {'error': 'short', 'ai': '01'}]], [[']C1\x1d2111-A/BXXB/111BB//\x1d0056127814768787889321/B---B-XBABBCA/\x1d115873', {'error': 'short', 'ai': '11'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C04009\x1d10X-CXA1/X\x1d310311958730', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C1310361473240011XBBC-1-CX1B-\x1d371255\x1d219X9B-C/', [['3103', '614732'], ['400', '11XBBC-1-CX1B-'], ['37', '1255'], ['21', '9X9B-C/']]], [']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']C117842129\x1d112821771705867701', {'error': 'short', 'ai': '01'}]], [[']C110XB/AC\x1d4001B/A9X///B9/CX-CC/B9\x1d17', {'error': 'short', 'ai': '17'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C111362276', [['11', '362276']]], [']C121C-\x1d3103238166', [['21', 'C-'], ['3103', '238166']]], [']C121-/1-X-9B\x1d17420369015026678280984317842704\x1d', [['21', '-/1-X-9B'], ['17', '420369'], ['01', '50266782809843'], ['17', '842704']]], [']C111990558117862\x1d10X-11\x1d0141668383672539', {'error': 'short', 'ai': '11'}], [']d2002942508545382808993103171446', {'error': 'not-gs1'}], [']C111216658400BAA--B9BX-A-BAC\x1d11370325113758', {'error': 'short', 'ai': '11'}]], [[']C1114640', {'error': 'short', 'ai': '11'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C11100096530067\x1d17348048', [['11', '000965'], ['30', '067'], ['17', '348048']]], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C1211CXX-B1B9XXX-/', [['21', '1CXX-B1B9XXX-/']]], [']C1308705431', [['30', '8705431']]], [']C010/ACC1C1C/9\x1d109\x1d00997634519263772689', {'error': 'not-gs1'}], [']C13103571576372081207\x1d016376737854687231039511', {'error': 'short', 'ai': '3103'}]], [[']C1018557077284519317', {'error': 'short', 'ai': '17'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C037218164131\x1d017878870121363103882288', {'error': 'not-gs1'}], [']C10109147699409412219X9/BACAA-C1/9X19-B\x1d21/\x1d17759960', [['01', '09147699409412'], ['21', '9X9/BACAA-C1/9X19-B'], ['21', '/'], ['17', '759960']]], [']C01109918000653062932206451941', {'error': 'not-gs1'}], [']C017335622\x1d10/A/1X9\x1d1019911-1X/1B1/C-B\x1d400AX/C', {'error': 'not-gs1'}], [']C121BCAB-C9CCX1/9X/CCX/1-A\x1d3103050801250114151498', {'error': 'length', 'ai': '21'}], [']C1113056571798553817202206\x1d00', {'error': 'short', 'ai': '00'}]]]
labels = ["regression: truncated fixed field", "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: truncated fixed field 0[['30', '38307'], ['21', 'B1CCBB9AAAX//'], ['11', '208584'], ['3103', '3208']]{'ai': '3103', 'error': 'short'}Failed
repair trap 1[['01', '0950110153000']]{'ai': '01', 'error': 'short'}Failed
combined fault 2{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 3{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 4[['17', '140648'], ['30', '6'], ['01', '41294680397442']][['17', '140648'], ['30', '6'], ['01', '41294680397442']]Passed
boundary 5{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
boundary 6{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 7[['01', '842115194162']]{'ai': '01', 'error': 'short'}Failed

SHA-256 / 759953fb173ec188d32b5b46af7d346c4012cee75105d9de22e0630931324d1e

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(']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 - 1 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 = [[[']C13038307\x1d21B1CCBB9AAAX//\x1d1120858431033208', {'error': 'short', 'ai': '3103'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C011400783', {'error': 'not-gs1'}], [']C03019\x1d10B9', {'error': 'not-gs1'}], [']C117140648306\x1d0141294680397442\x1d', [['17', '140648'], ['30', '6'], ['01', '41294680397442']]], [']d221B-1BA9-B\x1d219X91//1X9-/1A-C\x1d10BBCB1-9/-/9//-/BC1-A-X\x1d21/ABXAX9C-CC/-\x1d', {'error': 'not-gs1'}], [']C0\x1d3028612956', {'error': 'not-gs1'}], [']C1\x1d01842115194162', {'error': 'short', 'ai': '01'}]], [[']C1\x1d2111-A/BXXB/111BB//\x1d0056127814768787889321/B---B-XBABBCA/\x1d115873', {'error': 'short', 'ai': '11'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C04009\x1d10X-CXA1/X\x1d310311958730', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C1310361473240011XBBC-1-CX1B-\x1d371255\x1d219X9B-C/', [['3103', '614732'], ['400', '11XBBC-1-CX1B-'], ['37', '1255'], ['21', '9X9B-C/']]], [']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']C117842129\x1d112821771705867701', {'error': 'short', 'ai': '01'}]], [[']C110XB/AC\x1d4001B/A9X///B9/CX-CC/B9\x1d17', {'error': 'short', 'ai': '17'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C111362276', [['11', '362276']]], [']C121C-\x1d3103238166', [['21', 'C-'], ['3103', '238166']]], [']C121-/1-X-9B\x1d17420369015026678280984317842704\x1d', [['21', '-/1-X-9B'], ['17', '420369'], ['01', '50266782809843'], ['17', '842704']]], [']C111990558117862\x1d10X-11\x1d0141668383672539', {'error': 'short', 'ai': '11'}], [']d2002942508545382808993103171446', {'error': 'not-gs1'}], [']C111216658400BAA--B9BX-A-BAC\x1d11370325113758', {'error': 'short', 'ai': '11'}]], [[']C1114640', {'error': 'short', 'ai': '11'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C11100096530067\x1d17348048', [['11', '000965'], ['30', '067'], ['17', '348048']]], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C1211CXX-B1B9XXX-/', [['21', '1CXX-B1B9XXX-/']]], [']C1308705431', [['30', '8705431']]], [']C010/ACC1C1C/9\x1d109\x1d00997634519263772689', {'error': 'not-gs1'}], [']C13103571576372081207\x1d016376737854687231039511', {'error': 'short', 'ai': '3103'}]], [[']C1018557077284519317', {'error': 'short', 'ai': '17'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C037218164131\x1d017878870121363103882288', {'error': 'not-gs1'}], [']C10109147699409412219X9/BACAA-C1/9X19-B\x1d21/\x1d17759960', [['01', '09147699409412'], ['21', '9X9/BACAA-C1/9X19-B'], ['21', '/'], ['17', '759960']]], [']C01109918000653062932206451941', {'error': 'not-gs1'}], [']C017335622\x1d10/A/1X9\x1d1019911-1X/1B1/C-B\x1d400AX/C', {'error': 'not-gs1'}], [']C121BCAB-C9CCX1/9X/CCX/1-A\x1d3103050801250114151498', {'error': 'length', 'ai': '21'}], [']C1113056571798553817202206\x1d00', {'error': 'short', 'ai': '00'}]]]
labels = ["regression: truncated fixed field", "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: truncated fixed field 0{'ai': '3103', 'error': 'short'}{'ai': '3103', 'error': 'short'}Passed
repair trap 1[['01', '0950110153000']]{'ai': '01', 'error': 'short'}Failed
combined fault 2{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 3{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 4[['17', '140648'], ['30', '6'], ['01', '41294680397442']][['17', '140648'], ['30', '6'], ['01', '41294680397442']]Passed
boundary 5{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
boundary 6{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 7{'ai': '01', 'error': 'short'}{'ai': '01', 'error': 'short'}Passed

SHA-256 / 81f7687ae0d43cd80a11682c2af459098f52d8bcdedb372ee5f5900218047d02

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 = [[[']C13038307\x1d21B1CCBB9AAAX//\x1d1120858431033208', {'error': 'short', 'ai': '3103'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C011400783', {'error': 'not-gs1'}], [']C03019\x1d10B9', {'error': 'not-gs1'}], [']C117140648306\x1d0141294680397442\x1d', [['17', '140648'], ['30', '6'], ['01', '41294680397442']]], [']d221B-1BA9-B\x1d219X91//1X9-/1A-C\x1d10BBCB1-9/-/9//-/BC1-A-X\x1d21/ABXAX9C-CC/-\x1d', {'error': 'not-gs1'}], [']C0\x1d3028612956', {'error': 'not-gs1'}], [']C1\x1d01842115194162', {'error': 'short', 'ai': '01'}]], [[']C1\x1d2111-A/BXXB/111BB//\x1d0056127814768787889321/B---B-XBABBCA/\x1d115873', {'error': 'short', 'ai': '11'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C04009\x1d10X-CXA1/X\x1d310311958730', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C1310361473240011XBBC-1-CX1B-\x1d371255\x1d219X9B-C/', [['3103', '614732'], ['400', '11XBBC-1-CX1B-'], ['37', '1255'], ['21', '9X9B-C/']]], [']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']C117842129\x1d112821771705867701', {'error': 'short', 'ai': '01'}]], [[']C110XB/AC\x1d4001B/A9X///B9/CX-CC/B9\x1d17', {'error': 'short', 'ai': '17'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C111362276', [['11', '362276']]], [']C121C-\x1d3103238166', [['21', 'C-'], ['3103', '238166']]], [']C121-/1-X-9B\x1d17420369015026678280984317842704\x1d', [['21', '-/1-X-9B'], ['17', '420369'], ['01', '50266782809843'], ['17', '842704']]], [']C111990558117862\x1d10X-11\x1d0141668383672539', {'error': 'short', 'ai': '11'}], [']d2002942508545382808993103171446', {'error': 'not-gs1'}], [']C111216658400BAA--B9BX-A-BAC\x1d11370325113758', {'error': 'short', 'ai': '11'}]], [[']C1114640', {'error': 'short', 'ai': '11'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C11100096530067\x1d17348048', [['11', '000965'], ['30', '067'], ['17', '348048']]], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C1211CXX-B1B9XXX-/', [['21', '1CXX-B1B9XXX-/']]], [']C1308705431', [['30', '8705431']]], [']C010/ACC1C1C/9\x1d109\x1d00997634519263772689', {'error': 'not-gs1'}], [']C13103571576372081207\x1d016376737854687231039511', {'error': 'short', 'ai': '3103'}]], [[']C1018557077284519317', {'error': 'short', 'ai': '17'}], [']C1010950110153000', {'error': 'short', 'ai': '01'}], [']C037218164131\x1d017878870121363103882288', {'error': 'not-gs1'}], [']C10109147699409412219X9/BACAA-C1/9X19-B\x1d21/\x1d17759960', [['01', '09147699409412'], ['21', '9X9/BACAA-C1/9X19-B'], ['21', '/'], ['17', '759960']]], [']C01109918000653062932206451941', {'error': 'not-gs1'}], [']C017335622\x1d10/A/1X9\x1d1019911-1X/1B1/C-B\x1d400AX/C', {'error': 'not-gs1'}], [']C121BCAB-C9CCX1/9X/CCX/1-A\x1d3103050801250114151498', {'error': 'length', 'ai': '21'}], [']C1113056571798553817202206\x1d00', {'error': 'short', 'ai': '00'}]]]
labels = ["regression: truncated fixed field", "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: truncated fixed field 0{'ai': '3103', 'error': 'short'}{'ai': '3103', 'error': 'short'}Passed
repair trap 1{'ai': '01', 'error': 'short'}{'ai': '01', 'error': 'short'}Passed
combined fault 2{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 3{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 4[['17', '140648'], ['30', '6'], ['01', '41294680397442']][['17', '140648'], ['30', '6'], ['01', '41294680397442']]Passed
boundary 5{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
boundary 6{'error': 'not-gs1'}{'error': 'not-gs1'}Passed
control 7{'ai': '01', 'error': 'short'}{'ai': '01', 'error': 'short'}Passed

SHA-256 / abfeebccb1f25e844ed0e0cbf5eb39e78b349d5a688aae3a39fa2298335f30a8

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

Case digest / b9328eee950e4b8621fa8751bf51bcbb945252d0c1d6238caaa044414cdfead4