FAILURE MAP
← Case archive

FA-79626 / Barcode symbology encoding / Open access

Empty variable field swallows the following separator · case 01

A blank batch number followed by GS is parsed as a batch containing the next field.

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

ROOT CAUSE

The terminator search starts one character after the value start.

VERIFIED REPAIR

Search for GS from the first value character.

Unsuccessful approach: Stopping one character before the end drops the last character of a final field.

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 len(val) != n or '\x1d' in val:
                return {'error': 'short', 'ai': ai}
            i += n
        else:
            j = s.find('\x1d', i + 1)
            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 = [[[']C101172363105738253071239\x1d400\x1d374121746', {'error': 'length', 'ai': '400'}], [']C1306\x1d21ABB1A-1/-C/91X', [['30', '6'], ['21', 'ABB1A-1/-C/91X']]], [']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'}], [']C110\x1d0117751753362028\x1d0177258474173793', {'error': 'length', 'ai': '10'}]], [[']C1306\x1d30176449\x1d37\x1d', {'error': 'length', 'ai': '37'}], [']C117074388\x1d10ABCAA///BCA/B\x1d30850\x1d400CA1//9', [['17', '074388'], ['10', 'ABCAA///BCA/B'], ['30', '850'], ['400', 'CA1//9']]], [']C04009\x1d10X-CXA1/X\x1d310311958730', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']d23103386456', {'error': 'not-gs1'}], [']C110\x1d400BX11CB-\x1d400X11AC/XA/A/C9//X1/X-', {'error': 'length', 'ai': '10'}]], [[']C13733\x1d400\x1d', {'error': 'length', 'ai': '400'}], [']C1374\x1d370249383\x1d3786488334\x1d30836735', [['37', '4'], ['37', '0249383'], ['37', '86488334'], ['30', '836735']]], [']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'}], [']C1113049711168875537\x1d', {'error': 'length', 'ai': '37'}]], [[']C131038236223754346471\x1d10X-B/C\x1d10\x1d', {'error': 'length', 'ai': '10'}], [']C13099621984\x1d0182219701110065211CX/B//XC9-1B-XB\x1d10-B-/', [['30', '99621984'], ['01', '82219701110065'], ['21', '1CX/B//XC9-1B-XB'], ['10', '-B-/']]], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C010/ACC1C1C/9\x1d109\x1d00997634519263772689', {'error': 'not-gs1'}], [']C1211\x1d37789365790\x1d30311652\x1d', {'error': 'length', 'ai': '37'}], [']C13739\x1d11716656179637830183855146858643', [['37', '39'], ['11', '716656'], ['17', '963783'], ['01', '83855146858643']]], [']C03103992498', {'error': 'not-gs1'}], [']C130\x1d', {'error': 'length', 'ai': '30'}]], [[']C121CA1A1C99-B-BC1B-\x1d30\x1d10/XC\x1d00100406977233333568\x1d', {'error': 'length', 'ai': '30'}], [']C110--19BXXX9C\x1d11337975\x1d21/91/B', [['10', '--19BXXX9C'], ['11', '337975'], ['21', '/91/B']]], [']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'}], [']C10013804418417872807010\x1d', {'error': 'length', 'ai': '10'}]]]
labels = ["regression: variable field terminator search", "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: variable field terminator search 0[['01', '17236310573825'], ['30', '71239'], ['400', '\x1d374121746']]{'ai': '400', 'error': 'length'}Failed
repair trap 1[['30', '6'], ['21', 'ABB1A-1/-C/91X']][['30', '6'], ['21', 'ABB1A-1/-C/91X']]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[['10', '\x1d0117751753362028'], ['01', '77258474173793']]{'ai': '10', 'error': 'length'}Failed

SHA-256 / a8baee6c0ad8df3ce51e909e4244eee74f9b6dfd00a4de5319eb8dd17be43d44

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 or '\x1d' in val:
                return {'error': 'short', 'ai': ai}
            i += n
        else:
            j = s.find('\x1d', i) if '\x1d' in s[i:] else len(s) - 1
            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 = [[[']C101172363105738253071239\x1d400\x1d374121746', {'error': 'length', 'ai': '400'}], [']C1306\x1d21ABB1A-1/-C/91X', [['30', '6'], ['21', 'ABB1A-1/-C/91X']]], [']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'}], [']C110\x1d0117751753362028\x1d0177258474173793', {'error': 'length', 'ai': '10'}]], [[']C1306\x1d30176449\x1d37\x1d', {'error': 'length', 'ai': '37'}], [']C117074388\x1d10ABCAA///BCA/B\x1d30850\x1d400CA1//9', [['17', '074388'], ['10', 'ABCAA///BCA/B'], ['30', '850'], ['400', 'CA1//9']]], [']C04009\x1d10X-CXA1/X\x1d310311958730', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']d23103386456', {'error': 'not-gs1'}], [']C110\x1d400BX11CB-\x1d400X11AC/XA/A/C9//X1/X-', {'error': 'length', 'ai': '10'}]], [[']C13733\x1d400\x1d', {'error': 'length', 'ai': '400'}], [']C1374\x1d370249383\x1d3786488334\x1d30836735', [['37', '4'], ['37', '0249383'], ['37', '86488334'], ['30', '836735']]], [']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'}], [']C1113049711168875537\x1d', {'error': 'length', 'ai': '37'}]], [[']C131038236223754346471\x1d10X-B/C\x1d10\x1d', {'error': 'length', 'ai': '10'}], [']C13099621984\x1d0182219701110065211CX/B//XC9-1B-XB\x1d10-B-/', [['30', '99621984'], ['01', '82219701110065'], ['21', '1CX/B//XC9-1B-XB'], ['10', '-B-/']]], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C010/ACC1C1C/9\x1d109\x1d00997634519263772689', {'error': 'not-gs1'}], [']C1211\x1d37789365790\x1d30311652\x1d', {'error': 'length', 'ai': '37'}], [']C13739\x1d11716656179637830183855146858643', [['37', '39'], ['11', '716656'], ['17', '963783'], ['01', '83855146858643']]], [']C03103992498', {'error': 'not-gs1'}], [']C130\x1d', {'error': 'length', 'ai': '30'}]], [[']C121CA1A1C99-B-BC1B-\x1d30\x1d10/XC\x1d00100406977233333568\x1d', {'error': 'length', 'ai': '30'}], [']C110--19BXXX9C\x1d11337975\x1d21/91/B', [['10', '--19BXXX9C'], ['11', '337975'], ['21', '/91/B']]], [']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'}], [']C10013804418417872807010\x1d', {'error': 'length', 'ai': '10'}]]]
labels = ["regression: variable field terminator search", "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: variable field terminator search 0{'ai': '400', 'error': 'length'}{'ai': '400', 'error': 'length'}Passed
repair trap 1{'at': 22, 'error': 'unknown-ai'}[['30', '6'], ['21', 'ABB1A-1/-C/91X']]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': '10', 'error': 'length'}{'ai': '10', 'error': 'length'}Passed

SHA-256 / fddfe7f37c2aa2ba163375c6c3a98b54229f09c04ca0db1f8b3a9a8fa9e92337

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 = [[[']C101172363105738253071239\x1d400\x1d374121746', {'error': 'length', 'ai': '400'}], [']C1306\x1d21ABB1A-1/-C/91X', [['30', '6'], ['21', 'ABB1A-1/-C/91X']]], [']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'}], [']C110\x1d0117751753362028\x1d0177258474173793', {'error': 'length', 'ai': '10'}]], [[']C1306\x1d30176449\x1d37\x1d', {'error': 'length', 'ai': '37'}], [']C117074388\x1d10ABCAA///BCA/B\x1d30850\x1d400CA1//9', [['17', '074388'], ['10', 'ABCAA///BCA/B'], ['30', '850'], ['400', 'CA1//9']]], [']C04009\x1d10X-CXA1/X\x1d310311958730', {'error': 'not-gs1'}], [']C10044603095506351280311060380310300579483495402726338', {'error': 'unknown-ai', 'at': 41}], [']d211029205\x1d01139908024073283027281846\x1d10-X9C\x1d', {'error': 'not-gs1'}], [']C030473952263\x1d375323374', {'error': 'not-gs1'}], [']d23103386456', {'error': 'not-gs1'}], [']C110\x1d400BX11CB-\x1d400X11AC/XA/A/C9//X1/X-', {'error': 'length', 'ai': '10'}]], [[']C13733\x1d400\x1d', {'error': 'length', 'ai': '400'}], [']C1374\x1d370249383\x1d3786488334\x1d30836735', [['37', '4'], ['37', '0249383'], ['37', '86488334'], ['30', '836735']]], [']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'}], [']C1113049711168875537\x1d', {'error': 'length', 'ai': '37'}]], [[']C131038236223754346471\x1d10X-B/C\x1d10\x1d', {'error': 'length', 'ai': '10'}], [']C13099621984\x1d0182219701110065211CX/B//XC9-1B-XB\x1d10-B-/', [['30', '99621984'], ['01', '82219701110065'], ['21', '1CX/B//XC9-1B-XB'], ['10', '-B-/']]], [']C1211\x1d400/B-\x1d3067920\x1d', [['21', '1'], ['400', '/B-'], ['30', '67920']]], [']C010/ACC1C1C/9\x1d109\x1d00997634519263772689', {'error': 'not-gs1'}], [']C1211\x1d37789365790\x1d30311652\x1d', {'error': 'length', 'ai': '37'}], [']C13739\x1d11716656179637830183855146858643', [['37', '39'], ['11', '716656'], ['17', '963783'], ['01', '83855146858643']]], [']C03103992498', {'error': 'not-gs1'}], [']C130\x1d', {'error': 'length', 'ai': '30'}]], [[']C121CA1A1C99-B-BC1B-\x1d30\x1d10/XC\x1d00100406977233333568\x1d', {'error': 'length', 'ai': '30'}], [']C110--19BXXX9C\x1d11337975\x1d21/91/B', [['10', '--19BXXX9C'], ['11', '337975'], ['21', '/91/B']]], [']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'}], [']C10013804418417872807010\x1d', {'error': 'length', 'ai': '10'}]]]
labels = ["regression: variable field terminator search", "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: variable field terminator search 0{'ai': '400', 'error': 'length'}{'ai': '400', 'error': 'length'}Passed
repair trap 1[['30', '6'], ['21', 'ABB1A-1/-C/91X']][['30', '6'], ['21', 'ABB1A-1/-C/91X']]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': '10', 'error': 'length'}{'ai': '10', 'error': 'length'}Passed

SHA-256 / 9de84ed2ee1cf64463fc29c79d2cbdb87616a0b356ff05ce87823571a7b1653f

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

Case digest / b53c50a2833ded66754dc71762215ccf18aa09dab5dc8e61814da00d4d6d6fa4