FAILURE MAP
← Case archive

FA-96506 / Phone number formatting / Open access

Dial string from E.164: prefix overlap is mistaken for a domestic call · case 01

A DD caller dialing a BB number (+83...) gets a domestic dial string.

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

ROOT CAUSE

Domestic calls are detected by the digits starting with the caller code rather than by comparing the matched code.

VERIFIED REPAIR

Compare the matched destination code with the caller code for equality.

Unsuccessful approach: Testing whether the destination code occurs inside the caller code misclassifies BB callers dialing DD.

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 digits.startswith(own_cc):
        return trunk + nsn
    return exit_prefix + 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 code555012122100835550121221Failed
destination code is a prefix of caller code81085550101418108555010141Passed
three-digit exit prefix008915550135008915550135Passed
spaced E.164 rejectedNoneNonePassed
missing plus rejectedNoneNonePassed
leading zero instead of plus rejectedNoneNonePassed
unknown caller countryNoneNonePassed

SHA-256 / a33e7b0bd95ee53d451583db19fa4a79b4401b242513eaeeb04c7016178e3aea

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 in own_cc:
        return trunk + nsn
    return exit_prefix + 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 code85550101418108555010141Failed
three-digit exit prefix008915550135008915550135Passed
spaced E.164 rejectedNoneNonePassed
missing plus rejectedNoneNonePassed
leading zero instead of plus rejectedNoneNonePassed
unknown caller countryNoneNonePassed

SHA-256 / dbebe7343ad37996c6350e68b7c6ffad04592e203f02f373a504d5c6a8cb0056

3 / The verified repair

Exit 0
"""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 exit_prefix + 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 code81085550101418108555010141Passed
three-digit exit prefix008915550135008915550135Passed
spaced E.164 rejectedNoneNonePassed
missing plus rejectedNoneNonePassed
leading zero instead of plus rejectedNoneNonePassed
unknown caller countryNoneNonePassed

SHA-256 / e0302895b52b670e5ecd1f53486371d5d15a0821adaf64264b871480d1dfb506

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

Case digest / c6c3eec38f0a68cefe169580111a7a39a3f7a6d25bf2907eb034d7f524b6a668