Skip to content

docs(auth): correct the auth README against the GA API surface, and fix two broken exception messages - #2544

Open
demolaf wants to merge 3 commits into
masterfrom
docs/auth-readme-ga-api
Open

demolaf wants to merge 3 commits into
masterfrom
docs/auth-readme-ga-api

Conversation

@demolaf

@demolaf demolaf commented Oct 28, 2026

Copy link
Copy Markdown
Member

auth/README.md documented an API that does not exist: AuthState as a sealed hierarchy of data classes, an MFA section that builds a config object and never passes it anywhere, and an error when covering half the exception types with no else. Corrected against the source on pre-GA, with the hand-maintained test-tag table replaced by the naming rule the test suite already enforces.

Changes

  • AuthState block: abstract not sealed, nothing is a data class, Error.exception is typed Exception, plus Success.reauthenticatedUid, isNotification and the AuthState.Reauthentication hierarchy, with a note on what each means for caller code.

  • MFA Configuration now passes mfaConfiguration to FirebaseAuthScreen, which is where it goes. It is a screen parameter, not a property of authUIConfiguration, and the old example dropped the object it built.

  • Error Handling covers all 21 AuthException subclasses and ends with an else, since AuthException is not sealed and the missing branches previously failed silently.

  • Test tags: the 32-row table becomes the fui_<object_snake_case>_<CONSTANT_lowercase> rule, the 13 grouping objects, and a pointer to FirebaseAuthTestTags, citing the reflective assertions in FirebaseAuthTestTagsTest.

  • The stability promise is rescoped from "a value documented here" to every constant on FirebaseAuthTestTags, bringing the 27 constants the table omitted inside it.

  • Sign Out documents that signOut clears Google Credential Manager state and the Facebook LoginManager session for linked providers, with the Facebook step guarded by a classpath probe.

  • The FirebaseAuthScreen parameter table is marked partial and points at Custom UI with Slots for the seven slot parameters; the drifting "~170 abstract vals" count is dropped rather than re-pinned.

  • Fixes the localization example, which defined SpanishStringProvider with no constructor parameters and then called SpanishStringProvider(context), so the snippet did not compile.

  • Repairs two AuthException messages that read "You are are attempting...", the second also missing a word. Own commit, since it is source rather than docs.

Validation

Five sweeps re-run on the finished README: symbol resolution, named arguments against each callee, required arguments against each signature, Compose calling context, and anchor/TOC resolution (56 anchors, all resolve, modelling GitHub's duplicate-heading suffixing).

The string change carries ./gradlew :auth:testDebugUnitTest --rerun-tasks: BUILD SUCCESSFUL, 49 tasks executed, 1101 tests, 0 failures or errors. Verified as a real run rather than cached results by diffing the 82 test classes under auth/src/test against the 82 in auth/build/test-results, none missing, all XMLs written during this run.


Maintainer note: Refs internal CPRN-490

@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 centralizes the Android Lint configuration in the root build file, applying a uniform policy across all subprojects and removing redundant lint blocks from individual modules. It also refactors error handling and localization in the auth module, mapping specific Firebase Auth error codes to localized messages via AuthUIStringProvider, and improves session cleanup during sign-out. Additionally, ContinueUrlBuilder was refactored to use Uri for safer parameter appending, and numerous localized string resources were updated. The review feedback recommends ensuring the tools namespace is declared in all XML files using tools:ignore to prevent compilation errors, and suggests optimizing regex instantiation by extracting the pattern to a companion object constant.

locales. minimumPasswordLength is an unbounded Int, so 1 is reachable and would read
"at least 1 characters"; a policy of 1 is not worth 61 translations, and the check is
suppressed here rather than module-wide so it still guards every other string. -->
<string name="fui_error_password_too_short" tools:ignore="PluralsCandidate" translation_description="Error message when password is too short">Password must be at least %1$d characters long</string>

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.

high

Please ensure that xmlns:tools="http://schemas.android.com/tools" is declared in the root <resources> element of this file (and other regional strings.xml files like values-en-rAU, values-en-rCA, values-en-rGB where tools:ignore was added). If the namespace is not bound in the XML, AAPT2 will fail to compile the resources with a namespace binding error.

Comment on lines +1022 to +1023
private fun firstNumberIn(text: String): Int? =
Regex("\\d+").find(text)?.value?.toIntOrNull()

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.

medium

Instantiating a Regex object on every call to firstNumberIn is inefficient. It is recommended to extract the regular expression to a private companion object constant to avoid redundant object allocation.

Suggested change
private fun firstNumberIn(text: String): Int? =
Regex("\\d+").find(text)?.value?.toIntOrNull()
private val NUMBER_REGEX = Regex("\\d+")
private fun firstNumberIn(text: String): Int? =
NUMBER_REGEX.find(text)?.value?.toIntOrNull()

@demolaf
demolaf force-pushed the docs/auth-readme-ga-api branch from a13ce0a to f0883e5 Compare October 28, 2026 13:12
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