ADFA-4326: Guard uninitialized projectPath on process-death recreation#1414
ADFA-4326: Guard uninitialized projectPath on process-death recreation#1414fryanpan wants to merge 3 commits into
Conversation
|
Warning Review limit reached
More reviews will be available in 27 minutes and 27 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 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 |
Sentry APPDEVFORALL-QZ. Restore ProjectManagerImpl.projectPath from savedInstanceState -> intent PROJECT_PATH extra -> lastOpenedProject; guard projectDirPath getter; route back to MainActivity if still unset. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds ProjectManagerImplUninitializedPathTest covering the root cause of the EditorActivity crash after process-death recreation: reading ProjectManagerImpl.projectDirPath while the lateinit projectPath is unset. Pre-fix the getter delegated directly to the lateinit (get() = projectPath), throwing UninitializedPropertyAccessException; the fix guards with isInitialized and returns "" so the caller can route back to MainActivity. The test fails (UninitializedPropertyAccessException) on the pre-fix baseline and passes on the fix branch. A third case asserts the getter still reflects an assigned path, guarding against an always-blank regression. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
c2b5184 to
ea4b254
Compare
Jira Ticket: https://appdevforall.atlassian.net/browse/ADFA-4326
Sentry Issue: https://appdevforall-inc-9p.sentry.io/issues/APPDEVFORALL-QZ
Reproduction Details
After process death the OS can recreate
EditorActivitywithout routing throughMainActivity, leavingProjectManagerImpl'slateinit projectPathunset.EditorActivityreadsprojectDirPathduringonCreate(viaEditorViewModel.getProjectName → projectDir → projectDirPath); the getter delegated straight to the lateinit and threwUninitializedPropertyAccessException, failing activity start.Stack Trace
User Steps
User steps leading up to crash, based on Sentry breadcrumbs:
BaseApplication: Creating safe context because user is not unlocked→ direct-boot / credential-protected storage), thenEditorActivity/EditorSidebarFragmentare recreated with no project context → crash on firstprojectPathaccess.Was able to reproduce in a unit test?
Yes.
ProjectManagerImplUninitializedPathTest(:subprojects:projects, Robolectric) constructs a freshProjectManagerImpl(projectPath never set = the process-death state) and readsprojectDirPath/projectDir. Baseline: 2/3 cases FAIL withUninitializedPropertyAccessException(the 3rd, initialized, passes — not a tautology). Branch: 3/3 pass.What Was Fixed
Guarded getter —
get() = if (this::projectPath.isInitialized) projectPath else ""— andEditorViewModel/BaseEditorActivityroute back toMainActivityinstead of crashing when there's no project context.Testing
:subprojects:projects:testV8DebugUnitTest→ 3/3 green (red on baseline). Local CodeRabbit review: no findings. Reviewer notes (local): thefinish()+returnonly exitsBaseEditorActivity.onCreate— subclassonCreate(services/LSP/initializeProject) still runs on the finishing activity; consider short-circuiting earlier /isFinishingguards. TheEditorViewModelblank-path guard is redundant with the getter fix. Recommend an android-qa smoke of the process-death → editor-recreation path before close.Fixes APPDEVFORALL-QZ