fix(auth): localize user-facing auth errors by Firebase error code - #2509
fix(auth): localize user-facing auth errors by Firebase error code#2509demolaf wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances error handling and localization in FirebaseUI Auth by mapping specific Firebase Auth error codes to precise, localized user-facing messages. It introduces a new MisconfigurationException to safely handle developer setup errors without leaking raw diagnostics to users, and updates the exception mapping to correctly handle FirebaseTooManyRequestsException. Additionally, it updates localized string resources across numerous languages and adds comprehensive end-to-end unit tests. Feedback is provided regarding an inconsistency in AuthException.kt where the type-level hook used for ERROR_INVALID_USER_TOKEN and ERROR_USER_TOKEN_EXPIRED does not match the produced InvalidCredentialsException type.
…of duplicating it
…account-generic one
Fixes #2506.
AuthException.fromhad one flat arm forFirebaseAuthInvalidCredentialsException, so a wrong password, a mistyped SMS code and a malformed phone number all produced the same sentence, and the fourteen blankfui_error_*resources meant each fell through to the raw Firebase SDK diagnostic. That arm now branches onerrorCodelike its neighbours already did, and developer misconfiguration gets aMisconfigurationExceptionwhose message is generic translated copy with the diagnostic kept oncause.Pinning the code set against the SDK bytecode turned up two bugs:
ERROR_TOO_MANY_REQUESTSdoes not exist, so rate limiting fell through to the network branch and told throttled users they had no internet, andERROR_USER_CANCELLEDbecame an unknown error rather than a cancellation.Every string still sitting as English in a locale file is translated too, across all 84 folders. That gap is invisible to
MissingTranslationbecause the resources are present and merely hold the base text, which is whyvalues-zh-rTWshipped an English dialog title.Added
AuthExceptionRecoveryResolutionTest, which drives real Firebase exceptions throughfrom()into the dialog and asserts the result is never the SDK diagnostic.Preview
Japanese
Korean
Traditional Chinese