FA-95541 / Shipping rate zone lookup / Open access
International zones: unlisted countries rejected · case 01
Valid but unlisted countries are reported INVALID instead of rest of world.
ROOT CAUSE
The rest-of-world fallback is replaced by rejection.
THE FAILURE
The rest-of-world fallback is replaced by rejection.
Unsuccessful approach: Defaulting the lookup to 9 also accepts malformed 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 len(code) == 2 and code.isalpha():
return 'INVALID'
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 = [[['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 5', ['\tcu ', 'ECON'], 'BLOCKED']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 24', ['USA ', 'PRIORITY'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['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']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 53', [' USA ', 'ECON'], '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 26', ['\tau\n', 'PRIORITY'], 'Z5']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 24', ['USA ', 'PRIORITY'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| econ rest of world | INVALID | NO_SERVICE | Failed |
| digits invalid | INVALID | INVALID | Passed |
| padded lowercase | Z3 | Z3 | Passed |
| territory | DOMESTIC | DOMESTIC | Passed |
| priority rest of world | INVALID | Z9 | Failed |
| embargo lowercase | BLOCKED | BLOCKED | Passed |
| uk alias | Z3 | Z3 | Passed |
| generated mix 5 | BLOCKED | BLOCKED | Passed |
SHA-256 / fef6270b3dff531ed865c5826ed9c5c0c6d318b88db88b7a180a007580f04439
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, 9)
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 = [[['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['padded lowercase', [' gb ', 'PRIORITY'], 'Z3'], ['territory', ['PR', 'ECON'], 'DOMESTIC'], ['priority rest of world', ['ZA', 'PRIORITY'], 'Z9'], ['embargo lowercase', ['cu', 'PRIORITY'], 'BLOCKED'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['generated mix 5', ['\tcu ', 'ECON'], 'BLOCKED']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 24', ['USA ', 'PRIORITY'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['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']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 53', [' USA ', 'ECON'], '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 26', ['\tau\n', 'PRIORITY'], 'Z5']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['digits invalid', ['12', 'PRIORITY'], 'INVALID'], ['uk alias', ['uk', 'ECON'], 'Z3'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['alpha3 invalid', ['USA', 'PRIORITY'], 'INVALID'], ['canada econ', ['CA', 'ECON'], 'Z1'], ['generated mix 30', ['JP\n', 'PRIORITY'], 'Z4'], ['generated mix 38', ['\tBR\n', 'PRIORITY'], 'Z6']], [['econ rest of world', ['ZA', 'ECON'], 'NO_SERVICE'], ['generated mix 24', ['USA ', 'PRIORITY'], 'INVALID'], ['pacific territory', ['GU', 'PRIORITY'], 'DOMESTIC'], ['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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| econ rest of world | NO_SERVICE | NO_SERVICE | Passed |
| digits invalid | Z9 | INVALID | Failed |
| padded lowercase | Z3 | Z3 | Passed |
| territory | DOMESTIC | DOMESTIC | Passed |
| priority rest of world | Z9 | Z9 | Passed |
| embargo lowercase | BLOCKED | BLOCKED | Passed |
| uk alias | Z3 | Z3 | Passed |
| generated mix 5 | BLOCKED | BLOCKED | Passed |
SHA-256 / 1d0aa3e651ffab91f5cdca3250511136c14c308db03de5edaebd5f444475b808
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.617494+00:00.
Case digest / 99c9717412a6097bfc8baffa5f927bd1d806bb63aca4d29de877591e9804238c