FAILURE MAP
← Case archive

FA-96361 / Phone number formatting / Open access

Ten-digit display formatter: a plus sign with the wrong country is accepted · case 01

"+3025550115" formats as a domestic number although its country digit is missing.

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

ROOT CAUSE

Inputs with a leading plus are not required to carry country digit 1.

VERIFIED REPAIR

When the input starts with "+", require the digits to start with 1.

Unsuccessful approach: Requiring the character right after "+" to be 1 rejects "+ 1 302 555 0115".

Case contract

Strip the input. Only digits, spaces, parentheses, hyphens, dots and plus are allowed. If the input starts with "+" the digits must start with country digit 1. Eleven digits starting with 1 lose that 1. Exactly ten digits must remain: area (3), exchange (3), line (4). Neither the area nor the exchange may start with 0 or 1 or end in "11". Return "(AAA) EEE-LLLL" or None.

Why this case matters

Ten-digit display formatting is applied to every stored number; accepting impossible numbers or rejecting valid punctuation corrupts contact data.

1 / The failure

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

N = 1
observations = []
def solve(x):
    s = x.strip()
    if any(not (c.isdigit() or c in ' ()-.+') for c in s):
        return None
    d = ''.join(c for c in s if c.isdigit())
    if len(d) == 11 and d[0] == '1':
        d = d[1:]
    if len(d) != 10:
        return None
    a, e, sub = d[:3], d[3:6], d[6:]
    for part in (a, e):
        if part[0] in '01' or part[1:] == '11':
            return None
    return '(%s) %s-%s' % (a, e, sub)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['parenthesized input', '(302) 555-0115', '(302) 555-0115'], ['dotted input', '302.555.0115', '(302) 555-0115'], ['national prefix one', '1-302-555-0115', '(302) 555-0115'], ['plus one prefix', '+1 302 555 0115', '(302) 555-0115'], ['space after the plus', '+ 1 302 555 0115', '(302) 555-0115'], ['plus without country one', '+3025550115', None], ['eleven digits not starting with one', '23025550115', None], ['slash separators rejected', '302/555/0115', None], ['service-code area rejected', '211-555-0115', None], ['area code ending in one is fine', '201-555-0115', '(201) 555-0115'], ['exchange starting with one rejected', '302-155-0115', None], ['service-code exchange rejected', '302-511-0115', None]], [['parenthesized input', '(403) 555-0126', '(403) 555-0126'], ['dotted input', '403.555.0126', '(403) 555-0126'], ['national prefix one', '1-403-555-0126', '(403) 555-0126'], ['plus one prefix', '+1 403 555 0126', '(403) 555-0126'], ['space after the plus', '+ 1 403 555 0126', '(403) 555-0126'], ['plus without country one', '+4035550126', None], ['eleven digits not starting with one', '24035550126', None], ['slash separators rejected', '403/555/0126', None], ['service-code area rejected', '211-555-0126', None], ['area code ending in one is fine', '201-555-0126', '(201) 555-0126'], ['exchange starting with one rejected', '403-155-0126', None], ['service-code exchange rejected', '403-511-0126', None]], [['parenthesized input', '(504) 555-0137', '(504) 555-0137'], ['dotted input', '504.555.0137', '(504) 555-0137'], ['national prefix one', '1-504-555-0137', '(504) 555-0137'], ['plus one prefix', '+1 504 555 0137', '(504) 555-0137'], ['space after the plus', '+ 1 504 555 0137', '(504) 555-0137'], ['plus without country one', '+5045550137', None], ['eleven digits not starting with one', '25045550137', None], ['slash separators rejected', '504/555/0137', None], ['service-code area rejected', '211-555-0137', None], ['area code ending in one is fine', '201-555-0137', '(201) 555-0137'], ['exchange starting with one rejected', '504-155-0137', None], ['service-code exchange rejected', '504-511-0137', None]], [['parenthesized input', '(605) 555-0148', '(605) 555-0148'], ['dotted input', '605.555.0148', '(605) 555-0148'], ['national prefix one', '1-605-555-0148', '(605) 555-0148'], ['plus one prefix', '+1 605 555 0148', '(605) 555-0148'], ['space after the plus', '+ 1 605 555 0148', '(605) 555-0148'], ['plus without country one', '+6055550148', None], ['eleven digits not starting with one', '26055550148', None], ['slash separators rejected', '605/555/0148', None], ['service-code area rejected', '211-555-0148', None], ['area code ending in one is fine', '201-555-0148', '(201) 555-0148'], ['exchange starting with one rejected', '605-155-0148', None], ['service-code exchange rejected', '605-511-0148', None]], [['parenthesized input', '(706) 555-0159', '(706) 555-0159'], ['dotted input', '706.555.0159', '(706) 555-0159'], ['national prefix one', '1-706-555-0159', '(706) 555-0159'], ['plus one prefix', '+1 706 555 0159', '(706) 555-0159'], ['space after the plus', '+ 1 706 555 0159', '(706) 555-0159'], ['plus without country one', '+7065550159', None], ['eleven digits not starting with one', '27065550159', None], ['slash separators rejected', '706/555/0159', None], ['service-code area rejected', '211-555-0159', None], ['area code ending in one is fine', '201-555-0159', '(201) 555-0159'], ['exchange starting with one rejected', '706-155-0159', None], ['service-code exchange rejected', '706-511-0159', 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
parenthesized input(302) 555-0115(302) 555-0115Passed
dotted input(302) 555-0115(302) 555-0115Passed
national prefix one(302) 555-0115(302) 555-0115Passed
plus one prefix(302) 555-0115(302) 555-0115Passed
space after the plus(302) 555-0115(302) 555-0115Passed
plus without country one(302) 555-0115NoneFailed
eleven digits not starting with oneNoneNonePassed
slash separators rejectedNoneNonePassed
service-code area rejectedNoneNonePassed
area code ending in one is fine(201) 555-0115(201) 555-0115Passed
exchange starting with one rejectedNoneNonePassed
service-code exchange rejectedNoneNonePassed

SHA-256 / a49aaa53f252d66e2d4d5f242f0821587f7a8b433f13976cb0abfef23521b7ce

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    s = x.strip()
    if any(not (c.isdigit() or c in ' ()-.+') for c in s):
        return None
    d = ''.join(c for c in s if c.isdigit())
    if s.startswith('+') and s[1:2] != '1':
        return None
    if len(d) == 11 and d[0] == '1':
        d = d[1:]
    if len(d) != 10:
        return None
    a, e, sub = d[:3], d[3:6], d[6:]
    for part in (a, e):
        if part[0] in '01' or part[1:] == '11':
            return None
    return '(%s) %s-%s' % (a, e, sub)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['parenthesized input', '(302) 555-0115', '(302) 555-0115'], ['dotted input', '302.555.0115', '(302) 555-0115'], ['national prefix one', '1-302-555-0115', '(302) 555-0115'], ['plus one prefix', '+1 302 555 0115', '(302) 555-0115'], ['space after the plus', '+ 1 302 555 0115', '(302) 555-0115'], ['plus without country one', '+3025550115', None], ['eleven digits not starting with one', '23025550115', None], ['slash separators rejected', '302/555/0115', None], ['service-code area rejected', '211-555-0115', None], ['area code ending in one is fine', '201-555-0115', '(201) 555-0115'], ['exchange starting with one rejected', '302-155-0115', None], ['service-code exchange rejected', '302-511-0115', None]], [['parenthesized input', '(403) 555-0126', '(403) 555-0126'], ['dotted input', '403.555.0126', '(403) 555-0126'], ['national prefix one', '1-403-555-0126', '(403) 555-0126'], ['plus one prefix', '+1 403 555 0126', '(403) 555-0126'], ['space after the plus', '+ 1 403 555 0126', '(403) 555-0126'], ['plus without country one', '+4035550126', None], ['eleven digits not starting with one', '24035550126', None], ['slash separators rejected', '403/555/0126', None], ['service-code area rejected', '211-555-0126', None], ['area code ending in one is fine', '201-555-0126', '(201) 555-0126'], ['exchange starting with one rejected', '403-155-0126', None], ['service-code exchange rejected', '403-511-0126', None]], [['parenthesized input', '(504) 555-0137', '(504) 555-0137'], ['dotted input', '504.555.0137', '(504) 555-0137'], ['national prefix one', '1-504-555-0137', '(504) 555-0137'], ['plus one prefix', '+1 504 555 0137', '(504) 555-0137'], ['space after the plus', '+ 1 504 555 0137', '(504) 555-0137'], ['plus without country one', '+5045550137', None], ['eleven digits not starting with one', '25045550137', None], ['slash separators rejected', '504/555/0137', None], ['service-code area rejected', '211-555-0137', None], ['area code ending in one is fine', '201-555-0137', '(201) 555-0137'], ['exchange starting with one rejected', '504-155-0137', None], ['service-code exchange rejected', '504-511-0137', None]], [['parenthesized input', '(605) 555-0148', '(605) 555-0148'], ['dotted input', '605.555.0148', '(605) 555-0148'], ['national prefix one', '1-605-555-0148', '(605) 555-0148'], ['plus one prefix', '+1 605 555 0148', '(605) 555-0148'], ['space after the plus', '+ 1 605 555 0148', '(605) 555-0148'], ['plus without country one', '+6055550148', None], ['eleven digits not starting with one', '26055550148', None], ['slash separators rejected', '605/555/0148', None], ['service-code area rejected', '211-555-0148', None], ['area code ending in one is fine', '201-555-0148', '(201) 555-0148'], ['exchange starting with one rejected', '605-155-0148', None], ['service-code exchange rejected', '605-511-0148', None]], [['parenthesized input', '(706) 555-0159', '(706) 555-0159'], ['dotted input', '706.555.0159', '(706) 555-0159'], ['national prefix one', '1-706-555-0159', '(706) 555-0159'], ['plus one prefix', '+1 706 555 0159', '(706) 555-0159'], ['space after the plus', '+ 1 706 555 0159', '(706) 555-0159'], ['plus without country one', '+7065550159', None], ['eleven digits not starting with one', '27065550159', None], ['slash separators rejected', '706/555/0159', None], ['service-code area rejected', '211-555-0159', None], ['area code ending in one is fine', '201-555-0159', '(201) 555-0159'], ['exchange starting with one rejected', '706-155-0159', None], ['service-code exchange rejected', '706-511-0159', 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
parenthesized input(302) 555-0115(302) 555-0115Passed
dotted input(302) 555-0115(302) 555-0115Passed
national prefix one(302) 555-0115(302) 555-0115Passed
plus one prefix(302) 555-0115(302) 555-0115Passed
space after the plusNone(302) 555-0115Failed
plus without country oneNoneNonePassed
eleven digits not starting with oneNoneNonePassed
slash separators rejectedNoneNonePassed
service-code area rejectedNoneNonePassed
area code ending in one is fine(201) 555-0115(201) 555-0115Passed
exchange starting with one rejectedNoneNonePassed
service-code exchange rejectedNoneNonePassed

SHA-256 / b6fca85128577e516e01fae23c92b9f8c24401b3bdbaea6e52ed845558ce6539

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    s = x.strip()
    if any(not (c.isdigit() or c in ' ()-.+') for c in s):
        return None
    d = ''.join(c for c in s if c.isdigit())
    if s.startswith('+') and not d.startswith('1'):
        return None
    if len(d) == 11 and d[0] == '1':
        d = d[1:]
    if len(d) != 10:
        return None
    a, e, sub = d[:3], d[3:6], d[6:]
    for part in (a, e):
        if part[0] in '01' or part[1:] == '11':
            return None
    return '(%s) %s-%s' % (a, e, sub)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['parenthesized input', '(302) 555-0115', '(302) 555-0115'], ['dotted input', '302.555.0115', '(302) 555-0115'], ['national prefix one', '1-302-555-0115', '(302) 555-0115'], ['plus one prefix', '+1 302 555 0115', '(302) 555-0115'], ['space after the plus', '+ 1 302 555 0115', '(302) 555-0115'], ['plus without country one', '+3025550115', None], ['eleven digits not starting with one', '23025550115', None], ['slash separators rejected', '302/555/0115', None], ['service-code area rejected', '211-555-0115', None], ['area code ending in one is fine', '201-555-0115', '(201) 555-0115'], ['exchange starting with one rejected', '302-155-0115', None], ['service-code exchange rejected', '302-511-0115', None]], [['parenthesized input', '(403) 555-0126', '(403) 555-0126'], ['dotted input', '403.555.0126', '(403) 555-0126'], ['national prefix one', '1-403-555-0126', '(403) 555-0126'], ['plus one prefix', '+1 403 555 0126', '(403) 555-0126'], ['space after the plus', '+ 1 403 555 0126', '(403) 555-0126'], ['plus without country one', '+4035550126', None], ['eleven digits not starting with one', '24035550126', None], ['slash separators rejected', '403/555/0126', None], ['service-code area rejected', '211-555-0126', None], ['area code ending in one is fine', '201-555-0126', '(201) 555-0126'], ['exchange starting with one rejected', '403-155-0126', None], ['service-code exchange rejected', '403-511-0126', None]], [['parenthesized input', '(504) 555-0137', '(504) 555-0137'], ['dotted input', '504.555.0137', '(504) 555-0137'], ['national prefix one', '1-504-555-0137', '(504) 555-0137'], ['plus one prefix', '+1 504 555 0137', '(504) 555-0137'], ['space after the plus', '+ 1 504 555 0137', '(504) 555-0137'], ['plus without country one', '+5045550137', None], ['eleven digits not starting with one', '25045550137', None], ['slash separators rejected', '504/555/0137', None], ['service-code area rejected', '211-555-0137', None], ['area code ending in one is fine', '201-555-0137', '(201) 555-0137'], ['exchange starting with one rejected', '504-155-0137', None], ['service-code exchange rejected', '504-511-0137', None]], [['parenthesized input', '(605) 555-0148', '(605) 555-0148'], ['dotted input', '605.555.0148', '(605) 555-0148'], ['national prefix one', '1-605-555-0148', '(605) 555-0148'], ['plus one prefix', '+1 605 555 0148', '(605) 555-0148'], ['space after the plus', '+ 1 605 555 0148', '(605) 555-0148'], ['plus without country one', '+6055550148', None], ['eleven digits not starting with one', '26055550148', None], ['slash separators rejected', '605/555/0148', None], ['service-code area rejected', '211-555-0148', None], ['area code ending in one is fine', '201-555-0148', '(201) 555-0148'], ['exchange starting with one rejected', '605-155-0148', None], ['service-code exchange rejected', '605-511-0148', None]], [['parenthesized input', '(706) 555-0159', '(706) 555-0159'], ['dotted input', '706.555.0159', '(706) 555-0159'], ['national prefix one', '1-706-555-0159', '(706) 555-0159'], ['plus one prefix', '+1 706 555 0159', '(706) 555-0159'], ['space after the plus', '+ 1 706 555 0159', '(706) 555-0159'], ['plus without country one', '+7065550159', None], ['eleven digits not starting with one', '27065550159', None], ['slash separators rejected', '706/555/0159', None], ['service-code area rejected', '211-555-0159', None], ['area code ending in one is fine', '201-555-0159', '(201) 555-0159'], ['exchange starting with one rejected', '706-155-0159', None], ['service-code exchange rejected', '706-511-0159', 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
parenthesized input(302) 555-0115(302) 555-0115Passed
dotted input(302) 555-0115(302) 555-0115Passed
national prefix one(302) 555-0115(302) 555-0115Passed
plus one prefix(302) 555-0115(302) 555-0115Passed
space after the plus(302) 555-0115(302) 555-0115Passed
plus without country oneNoneNonePassed
eleven digits not starting with oneNoneNonePassed
slash separators rejectedNoneNonePassed
service-code area rejectedNoneNonePassed
area code ending in one is fine(201) 555-0115(201) 555-0115Passed
exchange starting with one rejectedNoneNonePassed
service-code exchange rejectedNoneNonePassed

SHA-256 / 482ef29c5b0baf243c88abc2bba28e3406d8c1bfc454efbaa2a6269874e74595

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

Case digest / 54772c2f4fdc094dc8e15b60df9d5f0e2c89eb4c6600bf928242dae40463538b