FAILURE MAP
← Case archive

FA-95521 / Shipping rate zone lookup / Open access

International zones: UK treated as unknown country · case 01

Shipments entered with country "UK" are rated as rest of world or refused for economy.

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

ROOT CAUSE

The common UK alias is not mapped to GB.

VERIFIED REPAIR

Map UK to GB before lookup.

Unsuccessful approach: Mapping GB to UK breaks the canonical code instead.

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 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 = [[['uk alias', ['uk', 'ECON'], 'Z3'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['generated mix 4', [' 12 ', 'ECON'], 'INVALID'], ['generated mix 12', ['PR ', 'ECON'], 'DOMESTIC']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 17', [' Uk', 'PRIORITY'], 'Z3'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 7', ['uk\n', 'ECON'], 'Z3'], ['generated mix 15', ['\tBR', 'PRIORITY'], 'Z6']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 43', ['\tgb\n', 'PRIORITY'], 'Z3'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 18', [' US\n', 'ECON'], 'DOMESTIC'], ['generated mix 26', ['\tau\n', 'PRIORITY'], 'Z5']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 6', ['\tUK', 'PRIORITY'], 'Z3'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 28', ['\tgb\n', 'ECON'], 'Z3'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 41', [' ZA ', 'PRIORITY'], 'Z9'], ['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
uk aliasNO_SERVICEZ3Failed
padded lowercaseZ3Z3Passed
pacific territoryDOMESTICDOMESTICPassed
priority rest of worldZ9Z9Passed
digits invalidINVALIDINVALIDPassed
territoryDOMESTICDOMESTICPassed
generated mix 4INVALIDINVALIDPassed
generated mix 12DOMESTICDOMESTICPassed

SHA-256 / 8e6b2f965468fcb3b7c148c881e7a4f46b32161bbe2c08dc4d8dd4d9c64279b8

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 == 'GB':
        code = 'UK'
    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 = [[['uk alias', ['uk', 'ECON'], 'Z3'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['generated mix 4', [' 12 ', 'ECON'], 'INVALID'], ['generated mix 12', ['PR ', 'ECON'], 'DOMESTIC']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 17', [' Uk', 'PRIORITY'], 'Z3'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 7', ['uk\n', 'ECON'], 'Z3'], ['generated mix 15', ['\tBR', 'PRIORITY'], 'Z6']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 43', ['\tgb\n', 'PRIORITY'], 'Z3'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 18', [' US\n', 'ECON'], 'DOMESTIC'], ['generated mix 26', ['\tau\n', 'PRIORITY'], 'Z5']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 6', ['\tUK', 'PRIORITY'], 'Z3'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 28', ['\tgb\n', 'ECON'], 'Z3'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 41', [' ZA ', 'PRIORITY'], 'Z9'], ['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
uk aliasNO_SERVICEZ3Failed
padded lowercaseZ9Z3Failed
pacific territoryDOMESTICDOMESTICPassed
priority rest of worldZ9Z9Passed
digits invalidINVALIDINVALIDPassed
territoryDOMESTICDOMESTICPassed
generated mix 4INVALIDINVALIDPassed
generated mix 12DOMESTICDOMESTICPassed

SHA-256 / af975f788079c2488a6cef349bebaa8ab1ebd95ca887bc521962d645df56bd78

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 = [[['uk alias', ['uk', 'ECON'], 'Z3'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['generated mix 4', [' 12 ', 'ECON'], 'INVALID'], ['generated mix 12', ['PR ', 'ECON'], 'DOMESTIC']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 17', [' Uk', 'PRIORITY'], 'Z3'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 7', ['uk\n', 'ECON'], 'Z3'], ['generated mix 15', ['\tBR', 'PRIORITY'], 'Z6']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 43', ['\tgb\n', 'PRIORITY'], 'Z3'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 18', [' US\n', 'ECON'], 'DOMESTIC'], ['generated mix 26', ['\tau\n', 'PRIORITY'], 'Z5']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 6', ['\tUK', 'PRIORITY'], 'Z3'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 28', ['\tgb\n', 'ECON'], 'Z3'], ['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['generated mix 41', [' ZA ', 'PRIORITY'], 'Z9'], ['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
uk aliasZ3Z3Passed
padded lowercaseZ3Z3Passed
pacific territoryDOMESTICDOMESTICPassed
priority rest of worldZ9Z9Passed
digits invalidINVALIDINVALIDPassed
territoryDOMESTICDOMESTICPassed
generated mix 4INVALIDINVALIDPassed
generated mix 12DOMESTICDOMESTICPassed

SHA-256 / 4b1cc5210f502be22776a0e7259b623427a366e98701082d4e31cfb5ded966f0

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

Case digest / 44e616cf51b9ae15a2fa63b4809c897a96424f19f71cc3418d51b79f9d784d14