FAILURE MAP
← Case archive

FA-95536 / Shipping rate zone lookup / Open access

International zones: three-letter codes accepted · case 01

Alpha-3 codes like "USA" are rated as rest of world.

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

ROOT CAUSE

The fallback group accepts any alphabetic string regardless of length.

VERIFIED REPAIR

Only two-letter alphabetic codes fall back to group 9.

Unsuccessful approach: Checking length alone accepts digit codes.

Case contract

country is an ISO alpha-2 code in any case with optional whitespace; "UK" is an alias of GB. US territories (US, PR, GU, VI, AS, MP) are DOMESTIC; embargoed CU, KP, IR, SY are BLOCKED. Listed countries map to groups 1-6; any other two-letter code is group 9; anything else INVALID. ECON is not offered to group 9 (NO_SERVICE). Return "Z<group>".

Why this case matters

International rating maps destination countries to zone groups.

1 / The failure

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

N = 1
observations = []
def solve(country, service):
    GROUPS = {'CA': 1, 'MX': 2, 'GB': 3, 'DE': 3, 'FR': 3, 'IE': 3, 'NL': 3, 'JP': 4, 'AU': 5, 'BR': 6}
    DOMESTIC = {'US', 'PR', 'GU', 'VI', 'AS', 'MP'}
    EMBARGO = {'CU', 'KP', 'IR', 'SY'}
    code = country.strip().upper()
    if code == 'UK':
        code = 'GB'
    if code in DOMESTIC:
        return 'DOMESTIC'
    if code in EMBARGO:
        return 'BLOCKED'
    zone = GROUPS.get(code)
    if zone is None:
        if code.isalpha():
            zone = 9
        else:
            return 'INVALID'
    if service == 'ECON' and zone == 9:
        return 'NO_SERVICE'
    return 'Z%d' % zone
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 4', [' 12 ', 'ECON'], 'INVALID'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 5', ['\tcu ', 'ECON'], 'BLOCKED']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 51', [' 12', 'ECON'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 7', ['uk\n', 'ECON'], 'Z3'], ['generated mix 15', ['\tBR', 'PRIORITY'], 'Z6']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 21', ['\tZ9 ', 'PRIORITY'], 'INVALID'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['generated mix 18', [' US\n', 'ECON'], 'DOMESTIC'], ['generated mix 27', ['IE\n', 'PRIORITY'], 'Z3']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 42', ['\tZ9 ', 'PRIORITY'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 40', ['\tIE\n', 'PRIORITY'], 'Z3'], ['generated mix 49', [' de', 'ECON'], 'Z3']]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
alpha3 invalidZ9INVALIDFailed
generated mix 4INVALIDINVALIDPassed
padded lowercaseZ3Z3Passed
territoryDOMESTICDOMESTICPassed
econ rest of worldNO_SERVICENO_SERVICEPassed
digits invalidINVALIDINVALIDPassed
uk aliasZ3Z3Passed
generated mix 5BLOCKEDBLOCKEDPassed

SHA-256 / 38cfc5bf8c65eb03e0ba5889437fa5422bc93204a9a65db7be2a771a644c9f5e

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(country, service):
    GROUPS = {'CA': 1, 'MX': 2, 'GB': 3, 'DE': 3, 'FR': 3, 'IE': 3, 'NL': 3, 'JP': 4, 'AU': 5, 'BR': 6}
    DOMESTIC = {'US', 'PR', 'GU', 'VI', 'AS', 'MP'}
    EMBARGO = {'CU', 'KP', 'IR', 'SY'}
    code = country.strip().upper()
    if code == 'UK':
        code = 'GB'
    if code in DOMESTIC:
        return 'DOMESTIC'
    if code in EMBARGO:
        return 'BLOCKED'
    zone = GROUPS.get(code)
    if zone is None:
        if len(code) == 2:
            zone = 9
        else:
            return 'INVALID'
    if service == 'ECON' and zone == 9:
        return 'NO_SERVICE'
    return 'Z%d' % zone
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 4', [' 12 ', 'ECON'], 'INVALID'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 5', ['\tcu ', 'ECON'], 'BLOCKED']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 51', [' 12', 'ECON'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 7', ['uk\n', 'ECON'], 'Z3'], ['generated mix 15', ['\tBR', 'PRIORITY'], 'Z6']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 21', ['\tZ9 ', 'PRIORITY'], 'INVALID'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['generated mix 18', [' US\n', 'ECON'], 'DOMESTIC'], ['generated mix 27', ['IE\n', 'PRIORITY'], 'Z3']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 42', ['\tZ9 ', 'PRIORITY'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 40', ['\tIE\n', 'PRIORITY'], 'Z3'], ['generated mix 49', [' de', 'ECON'], 'Z3']]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
alpha3 invalidINVALIDINVALIDPassed
generated mix 4NO_SERVICEINVALIDFailed
padded lowercaseZ3Z3Passed
territoryDOMESTICDOMESTICPassed
econ rest of worldNO_SERVICENO_SERVICEPassed
digits invalidZ9INVALIDFailed
uk aliasZ3Z3Passed
generated mix 5BLOCKEDBLOCKEDPassed

SHA-256 / d6e2338cfed3a8c3abe97ee9fa0aff243961df67a1b259f341023ef0adb626ea

3 / The verified repair

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

N = 1
observations = []
def solve(country, service):
    GROUPS = {'CA': 1, 'MX': 2, 'GB': 3, 'DE': 3, 'FR': 3, 'IE': 3, 'NL': 3, 'JP': 4, 'AU': 5, 'BR': 6}
    DOMESTIC = {'US', 'PR', 'GU', 'VI', 'AS', 'MP'}
    EMBARGO = {'CU', 'KP', 'IR', 'SY'}
    code = country.strip().upper()
    if code == 'UK':
        code = 'GB'
    if code in DOMESTIC:
        return 'DOMESTIC'
    if code in EMBARGO:
        return 'BLOCKED'
    zone = GROUPS.get(code)
    if zone is None:
        if len(code) == 2 and code.isalpha():
            zone = 9
        else:
            return 'INVALID'
    if service == 'ECON' and zone == 9:
        return 'NO_SERVICE'
    return 'Z%d' % zone
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 4', [' 12 ', 'ECON'], 'INVALID'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 5', ['\tcu ', 'ECON'], 'BLOCKED']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 51', [' 12', 'ECON'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 7', ['uk\n', 'ECON'], 'Z3'], ['generated mix 15', ['\tBR', 'PRIORITY'], 'Z6']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 21', ['\tZ9 ', 'PRIORITY'], 'INVALID'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['generated mix 18', [' US\n', 'ECON'], 'DOMESTIC'], ['generated mix 27', ['IE\n', 'PRIORITY'], 'Z3']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['generated mix 42', ['\tZ9 ', 'PRIORITY'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 40', ['\tIE\n', 'PRIORITY'], 'Z3'], ['generated mix 49', [' de', 'ECON'], 'Z3']]]
for label, args, expected in fixtures[N-1]:
    check(label, 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
alpha3 invalidINVALIDINVALIDPassed
generated mix 4INVALIDINVALIDPassed
padded lowercaseZ3Z3Passed
territoryDOMESTICDOMESTICPassed
econ rest of worldNO_SERVICENO_SERVICEPassed
digits invalidINVALIDINVALIDPassed
uk aliasZ3Z3Passed
generated mix 5BLOCKEDBLOCKEDPassed

SHA-256 / eb4664482e0b3629a1627e8c98d08f06622bf23beae591f98c57ca5048c4f14a

Verification & scope

Stipulated country table; not a sanctions or carrier coverage list. 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:52:14.572134+00:00.

Case digest / 6c45843ccbd28155ca5869e6b904ede6927cc6f31e46327e2e2af0e534029075