FAILURE MAP
← Case archive

FA-96511 / Phone number formatting / Open access

Dial string from E.164: international calls keep the plus sign · case 01

Foreign numbers are dialed as "+83..." from desk phones that need an exit prefix.

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

ROOT CAUSE

The plus sign is emitted instead of the caller exit prefix.

THE FAILURE

The plus sign is emitted instead of the caller exit prefix.

Unsuccessful approach: Hard-coding "00" is wrong for callers whose exit prefix is 810 or 011.

Case contract

Input [canonical +digits, caller country]. Toy table (code, exit prefix, trunk): DD 8/00/-, AA 42/00/0, BB 83/810/8, CC 891/011/-. The input must be "+" and digits only. The destination is the longest matching code. Same code as the caller: dial trunk + national number. Otherwise dial the caller exit prefix + code + national number. Unknown caller or code returns None.

Why this case matters

Click-to-call and PBX integrations dial the string produced here; a wrong prefix connects to a different subscriber or fails.

1 / The failure

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

N = 1
observations = []
def solve(x):
    e164, frm = x
    TABLE = {'DD': ('8', '00', ''), 'AA': ('42', '00', '0'), 'BB': ('83', '810', '8'), 'CC': ('891', '011', '')}
    if frm not in TABLE or not e164.startswith('+') or not e164[1:].isdigit():
        return None
    digits = e164[1:]
    cc = max((v[0] for v in TABLE.values() if digits.startswith(v[0])), key=len, default=None)
    if cc is None:
        return None
    nsn = digits[len(cc):]
    own_cc, exit_prefix, trunk = TABLE[frm]
    if cc == own_cc:
        return trunk + nsn
    return '+' + cc + nsn
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['domestic call adds trunk', ['+42555011123', 'AA'], '0555011123'], ['domestic call without trunk', ['+8915550135', 'CC'], '5550135'], ['caller code is a prefix of destination code', ['+835550121221', 'DD'], '00835550121221'], ['destination code is a prefix of caller code', ['+8555010141', 'BB'], '8108555010141'], ['three-digit exit prefix', ['+8915550135', 'AA'], '008915550135'], ['spaced E.164 rejected', ['+42 555011123', 'AA'], None], ['missing plus rejected', ['42555011123', 'AA'], None], ['leading zero instead of plus rejected', ['042555011123', 'AA'], None], ['unknown caller country', ['+42555011123', 'ZZ'], None]], [['domestic call adds trunk', ['+42555012234', 'AA'], '0555012234'], ['domestic call without trunk', ['+8915550246', 'CC'], '5550246'], ['caller code is a prefix of destination code', ['+835550122332', 'DD'], '00835550122332'], ['destination code is a prefix of caller code', ['+8555010252', 'BB'], '8108555010252'], ['three-digit exit prefix', ['+8915550246', 'AA'], '008915550246'], ['spaced E.164 rejected', ['+42 555012234', 'AA'], None], ['missing plus rejected', ['42555012234', 'AA'], None], ['leading zero instead of plus rejected', ['042555012234', 'AA'], None], ['unknown caller country', ['+42555012234', 'ZZ'], None]], [['domestic call adds trunk', ['+42555013345', 'AA'], '0555013345'], ['domestic call without trunk', ['+8915550357', 'CC'], '5550357'], ['caller code is a prefix of destination code', ['+835550123443', 'DD'], '00835550123443'], ['destination code is a prefix of caller code', ['+8555010363', 'BB'], '8108555010363'], ['three-digit exit prefix', ['+8915550357', 'AA'], '008915550357'], ['spaced E.164 rejected', ['+42 555013345', 'AA'], None], ['missing plus rejected', ['42555013345', 'AA'], None], ['leading zero instead of plus rejected', ['042555013345', 'AA'], None], ['unknown caller country', ['+42555013345', 'ZZ'], None]], [['domestic call adds trunk', ['+42555014456', 'AA'], '0555014456'], ['domestic call without trunk', ['+8915550468', 'CC'], '5550468'], ['caller code is a prefix of destination code', ['+835550124554', 'DD'], '00835550124554'], ['destination code is a prefix of caller code', ['+8555010474', 'BB'], '8108555010474'], ['three-digit exit prefix', ['+8915550468', 'AA'], '008915550468'], ['spaced E.164 rejected', ['+42 555014456', 'AA'], None], ['missing plus rejected', ['42555014456', 'AA'], None], ['leading zero instead of plus rejected', ['042555014456', 'AA'], None], ['unknown caller country', ['+42555014456', 'ZZ'], None]], [['domestic call adds trunk', ['+42555015567', 'AA'], '0555015567'], ['domestic call without trunk', ['+8915550579', 'CC'], '5550579'], ['caller code is a prefix of destination code', ['+835550125665', 'DD'], '00835550125665'], ['destination code is a prefix of caller code', ['+8555010585', 'BB'], '8108555010585'], ['three-digit exit prefix', ['+8915550579', 'AA'], '008915550579'], ['spaced E.164 rejected', ['+42 555015567', 'AA'], None], ['missing plus rejected', ['42555015567', 'AA'], None], ['leading zero instead of plus rejected', ['042555015567', 'AA'], None], ['unknown caller country', ['+42555015567', 'ZZ'], None]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), 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
domestic call adds trunk05550111230555011123Passed
domestic call without trunk55501355550135Passed
caller code is a prefix of destination code+83555012122100835550121221Failed
destination code is a prefix of caller code+85550101418108555010141Failed
three-digit exit prefix+8915550135008915550135Failed
spaced E.164 rejectedNoneNonePassed
missing plus rejectedNoneNonePassed
leading zero instead of plus rejectedNoneNonePassed
unknown caller countryNoneNonePassed

SHA-256 / ba7beb9d088091d4e2e2a6887d9b26e0d5d3135733fcb68ff2a36bc4b8223c4e

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    e164, frm = x
    TABLE = {'DD': ('8', '00', ''), 'AA': ('42', '00', '0'), 'BB': ('83', '810', '8'), 'CC': ('891', '011', '')}
    if frm not in TABLE or not e164.startswith('+') or not e164[1:].isdigit():
        return None
    digits = e164[1:]
    cc = max((v[0] for v in TABLE.values() if digits.startswith(v[0])), key=len, default=None)
    if cc is None:
        return None
    nsn = digits[len(cc):]
    own_cc, exit_prefix, trunk = TABLE[frm]
    if cc == own_cc:
        return trunk + nsn
    return '00' + cc + nsn
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['domestic call adds trunk', ['+42555011123', 'AA'], '0555011123'], ['domestic call without trunk', ['+8915550135', 'CC'], '5550135'], ['caller code is a prefix of destination code', ['+835550121221', 'DD'], '00835550121221'], ['destination code is a prefix of caller code', ['+8555010141', 'BB'], '8108555010141'], ['three-digit exit prefix', ['+8915550135', 'AA'], '008915550135'], ['spaced E.164 rejected', ['+42 555011123', 'AA'], None], ['missing plus rejected', ['42555011123', 'AA'], None], ['leading zero instead of plus rejected', ['042555011123', 'AA'], None], ['unknown caller country', ['+42555011123', 'ZZ'], None]], [['domestic call adds trunk', ['+42555012234', 'AA'], '0555012234'], ['domestic call without trunk', ['+8915550246', 'CC'], '5550246'], ['caller code is a prefix of destination code', ['+835550122332', 'DD'], '00835550122332'], ['destination code is a prefix of caller code', ['+8555010252', 'BB'], '8108555010252'], ['three-digit exit prefix', ['+8915550246', 'AA'], '008915550246'], ['spaced E.164 rejected', ['+42 555012234', 'AA'], None], ['missing plus rejected', ['42555012234', 'AA'], None], ['leading zero instead of plus rejected', ['042555012234', 'AA'], None], ['unknown caller country', ['+42555012234', 'ZZ'], None]], [['domestic call adds trunk', ['+42555013345', 'AA'], '0555013345'], ['domestic call without trunk', ['+8915550357', 'CC'], '5550357'], ['caller code is a prefix of destination code', ['+835550123443', 'DD'], '00835550123443'], ['destination code is a prefix of caller code', ['+8555010363', 'BB'], '8108555010363'], ['three-digit exit prefix', ['+8915550357', 'AA'], '008915550357'], ['spaced E.164 rejected', ['+42 555013345', 'AA'], None], ['missing plus rejected', ['42555013345', 'AA'], None], ['leading zero instead of plus rejected', ['042555013345', 'AA'], None], ['unknown caller country', ['+42555013345', 'ZZ'], None]], [['domestic call adds trunk', ['+42555014456', 'AA'], '0555014456'], ['domestic call without trunk', ['+8915550468', 'CC'], '5550468'], ['caller code is a prefix of destination code', ['+835550124554', 'DD'], '00835550124554'], ['destination code is a prefix of caller code', ['+8555010474', 'BB'], '8108555010474'], ['three-digit exit prefix', ['+8915550468', 'AA'], '008915550468'], ['spaced E.164 rejected', ['+42 555014456', 'AA'], None], ['missing plus rejected', ['42555014456', 'AA'], None], ['leading zero instead of plus rejected', ['042555014456', 'AA'], None], ['unknown caller country', ['+42555014456', 'ZZ'], None]], [['domestic call adds trunk', ['+42555015567', 'AA'], '0555015567'], ['domestic call without trunk', ['+8915550579', 'CC'], '5550579'], ['caller code is a prefix of destination code', ['+835550125665', 'DD'], '00835550125665'], ['destination code is a prefix of caller code', ['+8555010585', 'BB'], '8108555010585'], ['three-digit exit prefix', ['+8915550579', 'AA'], '008915550579'], ['spaced E.164 rejected', ['+42 555015567', 'AA'], None], ['missing plus rejected', ['42555015567', 'AA'], None], ['leading zero instead of plus rejected', ['042555015567', 'AA'], None], ['unknown caller country', ['+42555015567', 'ZZ'], None]]]
for label, arg, expected in fixtures[N - 1]:
    check(label, solve(arg), 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
domestic call adds trunk05550111230555011123Passed
domestic call without trunk55501355550135Passed
caller code is a prefix of destination code0083555012122100835550121221Passed
destination code is a prefix of caller code0085550101418108555010141Failed
three-digit exit prefix008915550135008915550135Passed
spaced E.164 rejectedNoneNonePassed
missing plus rejectedNoneNonePassed
leading zero instead of plus rejectedNoneNonePassed
unknown caller countryNoneNonePassed

SHA-256 / ffdea177887ebf6e9b250730b8d4fb7ba91b530c45c74272947a903f1e6fe9fd

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 9 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

A deterministic toy contract over synthetic, obviously fictitious telephone numbers and toy country tables. The rules are stipulated for this model only and make no claim of conformance with any numbering plan or telecommunications standard. 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:23.488569+00:00.

Case digest / b8585b3406e90a592feb2d914860045294770e339b05f7b5c1a0fb867b8b2c03