ory/kratos · error
the provided number is not a valid phone number
Error message
the provided number is not a valid phone number
What it means
NormalizeIdentifier parses a value with the phonenumbers library when the schema annotation requests phone normalization. If the parsed number is not a valid phone number for any region, it refuses to normalize and returns this error, because storing an invalid E.164 identifier would corrupt identity matching.
Solutions
- Provide the number in full international E.164 format, e.g. +14155552671
- Add a default country code in the identity schema's normalization options so national formats can be resolved
- Validate the phone number client-side (format + plausible country) before submitting the flow
- Fix imported/migrated data with a phone validation library before creating identities
Example fix
// before
{"traits": {"phone": "555-1234"}}
// after
{"traits": {"phone": "+14155551234"}} Defensive patterns
Strategy: validation
Validate before calling
p, err := phonenumbers.Parse(value, defaultRegion); if err != nil || !phonenumbers.IsValidNumber(p) { /* reject before submit */ } Prevention
- Collect phones in E.164 format from the UI
- Set a default region in schema normalization options
- Sanitize imported datasets with a phone validator
- Reject obvious placeholders like 0000000000
When it happens
Trigger: Registering/submitting a trait whose identity schema uses the phone normalization annotation, with a string that parses but fails phonenumbers.IsValidNumber (wrong country code, impossible number, or a non-phone string like '12345').
Common situations: Users typing a national number without a country code that cannot be inferred; placeholders like '000-000-0000'; schemas defaulting to region '' so no default country applies; migration scripts importing junk phone values.
Understand the failure class
Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.
Related errors
- you must provide `secrets.pagination` for FIPS compliance
- courier: email recipient is not a valid email address
- failed to decode PEM block containing private key
- Private key is not ecdsa key
- no oidc provider was set
AI-assisted analysis of ory/kratos@b86338da04 (2026-09-07).
Data as JSON: /api/errors/0890647d04faad2a.
Report an issue: GitHub.
Appendix: source
Thrown at x/normalize.go:158
return "", err
}
email, err := mail.ParseAddress(value)
if err != nil {
return "", err
}
return email.Address, nil
case "sms":
value, err := applyPRECIS(phoneProfile, value, false)
if err != nil {
return "", err
}
number, err := phonenumbers.Parse(value, "")
if err != nil {
return "", err
}
if !phonenumbers.IsValidNumber(number) {
return "", errors.New("the provided number is not a valid phone number")
}
return phonenumbers.Format(number, phonenumbers.E164), nil
case "username":
fallthrough
default:
return applyPRECIS(emailProfile, value, true)
}
}
View on GitHub (pinned to b86338da04)