fix(ui): surface sign-in-only auth errors - #834
Conversation
📝 WalkthroughWalkthroughSign-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. ChangesSign-in error handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
source/ui/src/test/java/com/clerk/ui/auth/AuthViewModelTest.kt (1)
86-107: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the invitation fallback code.
The supplied fallback test covers
form_identifier_not_found, but notinvitation_account_not_exists, which is now an explicit branch inAuthStartViewModel.signIn. Add aSignInOrUptest asserting that this code invokesSignUp.createand reachesSignUpSuccess.🤖 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 winUse
whenfor theSignIn.create(...)failure routing.This path still uses
.onFailure; wrapSignIn.create(...)withwhen (val result = ...)and move theshouldSignUpfallback into theClerkResult.Failurebranch to match theClerkResultpattern.🤖 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
📒 Files selected for processing (2)
source/ui/src/main/java/com/clerk/ui/auth/AuthStartViewModel.ktsource/ui/src/test/java/com/clerk/ui/auth/AuthViewModelTest.kt
What & why
AuthMode.SignInfailures remaining inLoadingindefinitely.AuthState.Error.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
AuthStartViewModel.signInand 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.
Note
Fix
AuthStartViewModel.startAuthto surface errors in sign-in-only modeIn sign-in-only mode (
withSignUp = false), auth failures never updated state, leaving the UI stuck onLoadingwith no error shown. TheonFailurebranch inAuthStartViewModel.ktwas gated on aClerkErrorResponsetype check inside awithSignUpcondition, so all failures in sign-in mode were silently dropped. The fix removes the type check and always emitsAuthState.Errorunless 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