fix: prevent NPE crash on KYC date of birth picker#2022
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR addresses a null-pointer crash in the KYC Level 1 date-of-birth picker, fixes the vulnerable confirm handler with null-safe binding, and introduces a comprehensive test suite with in-memory repository fakes to validate ViewModel behavior across initialization, validation, state loading, and dialog lifecycle scenarios. ChangesKYC Level 1 ViewModel Testing & Crash Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
Description
What's the problem?
The KYC Level 1 date of birth picker used a non-null assertion (
!!) onselectedDateMillis. During rapid taps or recomposition while theAnimatedVisibilityanimation was running, the value could temporarily becomenulleven though the confirm button remained enabled, causing aNullPointerExceptioncrash.What's the fix?
Fixes #2021
Replaced the unsafe non-null assertion with a safe
?.letcall so the action is skipped safely if the selected date becomesnullat tap time.Changes
KYCLevel1Screen.kt— replaced unsafe!!with safe null handling on DOB confirmationKYCLevel1ViewModelTest.kt— added 7 unit tests coveringDobChangedflowTestFakes.kt— added fake repositories for ViewModel testingbuild.gradle.kts— added Turbine dependency for Flow testingTesting
Apply the
AndroidStyle.xmlstyle template to your code in Android Studio.Run the unit tests with
./gradlew checkto make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests