Fix Bug (Systematic Bug Fixing)
Systematically investigate the reported bug, identify the root cause, and fix it.
Step 1: Understand the Bug
- •Organize the bug report
- •Identify reproduction conditions
- •Clarify expected vs actual behavior
Step 2: Root Cause Investigation
Investigate from the following perspectives:
Architecture-Related
- •Is the UDF flow broken (trace the state update path)?
- •Is the ViewModel state updated correctly?
- •Are there issues in the Repository → DataSource data flow?
- •Is the DI scope correct (unexpected instance sharing)?
Lifecycle-Related
- •Inconsistencies during Activity/Fragment state transitions
- •State loss on configuration change (rotation)
- •Resource release leaks (Camera, Listener, Receiver, etc.)
- •Issues with
LifecycleOwnerscope
Compose-Related
- •State not updating correctly (
mutableStateOfvsMutableStateFlow) - •Recomposition timing issues
- •
rememberkey is incorrect, referencing stale values - •Side effect execution order
- •
LaunchedEffectnot re-executing because key doesn't change
Async/Concurrency-Related
- •UI updates from non-main thread
- •Coroutine cancellation handling
- •Race conditions
- •Coroutine launched outside
viewModelScope
Data-Related
- •Null pointer (bypassing Kotlin null safety)
- •Type mismatch, invalid casting
- •Missing handling for empty collections
Step 3: Fix
- •Apply the minimum change needed to fix the issue
- •Follow existing architecture patterns
- •Add comments explaining the fix rationale (only for complex fixes)
Step 4: Verification
bash
./gradlew assembleDebug # Build check ./gradlew test # Regression check
- •Add regression tests if needed
Step 5: Fix Report
code
## Bug Fix Report - **Root Cause**: Root cause description - **Fix**: What was changed - **Impact**: Impact on other features - **Tests**: Tests added/verified - **Prevention**: Suggestions to prevent recurrence (if any)
Target Bug
$ARGUMENTS