Skip to content

fix(ui): surface sign-in-only auth errors - #834

Merged
swolfand merged 1 commit into
mainfrom
sam/mobile-602-spike-sign-in-only-mode-swallows-auth-errors
Jul 30, 2026
Merged

fix(ui): surface sign-in-only auth errors#834
swolfand merged 1 commit into
mainfrom
sam/mobile-602-spike-sign-in-only-mode-swallows-auth-errors

Conversation

@swolfand

@swolfand swolfand commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

What & why

  • Fix AuthMode.SignIn failures remaining in Loading indefinitely.
  • Preserve the sign-in-or-up fallback only for identifier-not-found and invitation-account-not-found errors.
  • Surface all other API and unknown/network failures through AuthState.Error.
  • Add regression coverage for API and unknown failures in sign-in-only mode.

The failure handler previously gated its entire body on withSignUp, so sign-in-only attempts never updated UI state after an error.

Linear: MOBILE-602

What to focus on

  • The fallback condition in AuthStartViewModel.signIn and whether any additional errors should transfer into sign-up.

Screenshots / video

Manually verified with the workbench configured in sign-in-only mode: an invalid identifier surfaces an error instead of leaving the Continue button loading.

image

Note

Fix AuthStartViewModel.startAuth to surface errors in sign-in-only mode

In sign-in-only mode (withSignUp = false), auth failures never updated state, leaving the UI stuck on Loading with no error shown. The onFailure branch in AuthStartViewModel.kt was gated on a ClerkErrorResponse type check inside a withSignUp condition, so all failures in sign-in mode were silently dropped. The fix removes the type check and always emits AuthState.Error unless the error code warrants a sign-up fallback.

🖇️ Linked Issues

Resolves MOBILE-602, which identified that wrong identifier, throttle, and network errors in sign-in-only mode left the UI in a permanent loading state.

Macroscope summarized 7b38636.

Summary by CodeRabbit

  • Bug Fixes
    • Improved sign-in error handling to correctly distinguish recoverable errors from unexpected failures.
    • Sign-in now displays the relevant backend error message when available, or a clear generic message when no details are provided.
  • Tests
    • Added coverage for API and unknown sign-in failure scenarios, including expected loading and error state transitions.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Sign-in failure handling now checks backend error codes directly to decide between sign-up fallback and error state emission. Tests cover API failures with specific messages and unknown failures with the generic message.

Changes

Sign-in error handling

Layer / File(s) Summary
Update sign-in failure routing
source/ui/src/main/java/com/clerk/ui/auth/AuthStartViewModel.kt, source/ui/src/test/java/com/clerk/ui/auth/AuthViewModelTest.kt
Recognized form and invitation error codes trigger sign-up; other API and unknown failures emit AuthState.Error with the appropriate message, covered by new tests.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: surfacing sign-in-only auth errors.
Description check ✅ Passed The description matches the required template and includes the change rationale, reviewer focus, and screenshots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sam/mobile-602-spike-sign-in-only-mode-swallows-auth-errors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@swolfand
swolfand marked this pull request as ready for review July 30, 2026 19:32

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (2)
source/ui/src/test/java/com/clerk/ui/auth/AuthViewModelTest.kt (1)

86-107: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the invitation fallback code.

The supplied fallback test covers form_identifier_not_found, but not invitation_account_not_exists, which is now an explicit branch in AuthStartViewModel.signIn. Add a SignInOrUp test asserting that this code invokes SignUp.create and reaches SignUpSuccess.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@source/ui/src/test/java/com/clerk/ui/auth/AuthViewModelTest.kt` around lines
86 - 107, Add a SignInOrUp test covering the invitation_account_not_exists
branch in AuthStartViewModel.signIn. Mock SignInOrUp to return that API error,
verify SignUp.create is invoked with the expected parameters, and assert the
flow reaches SignUpSuccess.
source/ui/src/main/java/com/clerk/ui/auth/AuthStartViewModel.kt (1)

182-188: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use when for the SignIn.create(...) failure routing.

This path still uses .onFailure; wrap SignIn.create(...) with when (val result = ...) and move the shouldSignUp fallback into the ClerkResult.Failure branch to match the ClerkResult pattern.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@source/ui/src/main/java/com/clerk/ui/auth/AuthStartViewModel.kt` around lines
182 - 188, Replace the SignIn.create(...).onFailure routing with when (val
result = SignIn.create(...)), handling success and ClerkResult.Failure
explicitly. Move the matchingCodes/shouldSignUp fallback into the
ClerkResult.Failure branch, preserving signUp for matching errors and
AuthState.Error for all other failures.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@source/ui/src/main/java/com/clerk/ui/auth/AuthStartViewModel.kt`:
- Around line 182-188: Replace the SignIn.create(...).onFailure routing with
when (val result = SignIn.create(...)), handling success and ClerkResult.Failure
explicitly. Move the matchingCodes/shouldSignUp fallback into the
ClerkResult.Failure branch, preserving signUp for matching errors and
AuthState.Error for all other failures.

In `@source/ui/src/test/java/com/clerk/ui/auth/AuthViewModelTest.kt`:
- Around line 86-107: Add a SignInOrUp test covering the
invitation_account_not_exists branch in AuthStartViewModel.signIn. Mock
SignInOrUp to return that API error, verify SignUp.create is invoked with the
expected parameters, and assert the flow reaches SignUpSuccess.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 203371ef-5373-4055-862d-4b122315a453

📥 Commits

Reviewing files that changed from the base of the PR and between c24f404 and 7b38636.

📒 Files selected for processing (2)
  • source/ui/src/main/java/com/clerk/ui/auth/AuthStartViewModel.kt
  • source/ui/src/test/java/com/clerk/ui/auth/AuthViewModelTest.kt

@swolfand
swolfand merged commit f2a83f2 into main Jul 30, 2026
17 checks passed
@swolfand
swolfand deleted the sam/mobile-602-spike-sign-in-only-mode-swallows-auth-errors branch July 30, 2026 19:52
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