Distinguish empty token from user_id mismatch at connect - #6624
Conversation
Backport of #6622 to v6. Split the check in setUser() on token.isBlank() and tag each branch with a stable code from the existing ChatErrorCode. Both stay GenericError and the returned message is unchanged from the previous behaviour, so callers that match on it are not broken; the code is the discriminator: - blank token -> code UNDEFINED_TOKEN (1007) - user_id != id -> code INVALID_TOKEN (1006) Requires stream-result 1.4.1 (adds GenericError.code, JVM 11); streamResult bumped 1.3.2 -> 1.4.1.
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
WalkthroughThe PR updates ChangesToken Error Classification
streamResult Dependency Update
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 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 |
SDK Size Comparison 📏
|
|



Goal
Closes AND-1374
Backport of #6622 to
v6. When theTokenProviderreturns a blank token (e.g. offline),setUser()returned the sameError.GenericErrorand message as a genuine user_id mismatch — indistinguishable. Callers can now branch onerror.code. Merge after the primary #6622 lands (full review happens there).Implementation
v6: inChatClient.setUser(), checktoken.isBlank()before the user_id comparison and tag each failure with a stable code from the existingChatErrorCode— both stayError.GenericErrorwith the message unchanged (no break for message-matchers); thecodeis the discriminator:UNDEFINED_TOKEN(1007)user_id != user.id→INVALID_TOKEN(1006)GenericError.codefrom stream-result 1.4.1 (additive slot, JVM 11);streamResultbumped1.3.2 → 1.4.1on v6.Testing
ChatClientConnectionTests: 27 tests, 0 failures (extended mismatch test assertsINVALID_TOKEN; new blank-token test assertsUNDEFINED_TOKEN+ unchanged message)../gradlew :stream-chat-android-client:spotlessCheckpasses.Summary by CodeRabbit
Bug Fixes
Maintenance