Skip to content

fix(auth): localize user-facing auth errors by Firebase error code - #2509

Open
demolaf wants to merge 8 commits into
auth/error-string-providerfrom
auth/localize-error-codes
Open

fix(auth): localize user-facing auth errors by Firebase error code#2509
demolaf wants to merge 8 commits into
auth/error-string-providerfrom
auth/localize-error-codes

Conversation

@demolaf

@demolaf demolaf commented Sep 11, 2026

Copy link
Copy Markdown
Member

Fixes #2506.

AuthException.from had one flat arm for FirebaseAuthInvalidCredentialsException, so a wrong password, a mistyped SMS code and a malformed phone number all produced the same sentence, and the fourteen blank fui_error_* resources meant each fell through to the raw Firebase SDK diagnostic. That arm now branches on errorCode like its neighbours already did, and developer misconfiguration gets a MisconfigurationException whose message is generic translated copy with the diagnostic kept on cause.

Pinning the code set against the SDK bytecode turned up two bugs: ERROR_TOO_MANY_REQUESTS does not exist, so rate limiting fell through to the network branch and told throttled users they had no internet, and ERROR_USER_CANCELLED became 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 MissingTranslation because the resources are present and merely hold the base text, which is why values-zh-rTW shipped an English dialog title.

Added AuthExceptionRecoveryResolutionTest, which drives real Firebase exceptions through from() into the dialog and asserts the result is never the SDK diagnostic.

Preview

Japanese

Before After
before-1-ja after-1-ja

Korean

Before After
before-2-ko after-2-ko

Traditional Chinese

Before After
before-3-zh-TW after-3-zh-TW

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread auth/src/main/java/com/firebase/ui/auth/AuthException.kt Outdated
@demolaf
demolaf marked this pull request as ready for review September 11, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant