Repository navigation
fix: do nothing instead of throwing on calls before init - #2829
Draft
fadi-george wants to merge 2 commits into
Draft
fadi-george wants to merge 2 commits into
fadi-george wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
📊 Diff Coverage ReportDiff Coverage Report (Changed Lines Only)Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff). Changed Files Coverage
Overall (aggregate gate)28/87 touched executable lines covered (32.2% — requires ≥ 80%) Per-file detail (informational; gate is aggregate above):
❌ Coverage Check FailedAggregate coverage on touched lines is 32.2% (minimum 80%). |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Calls before init, or after a failed init, log and do nothing instead of throwing:
login,logout,updateUserJwt, the JWT listeners, and theUser,Notifications,InAppMessages,LocationandSessionaccessors.Details
Motivation
A simpler alternative to the never-crash stack (#2800 to #2828) for the most common crash: calling
loginand friends beforeinitWithContext, or after it failed. It reuses the existing init state andwaitForInitinstead of adding a new gate, deferred managers or a kill switch.Scope
NOT_STARTED) or after a failed init (FAILED), these calls log'<op>' ignored: ...with the init failure attached and return:login,logout,updateUserJwt,add/removeUserJwtInvalidatedListener,loginSuspend,logoutSuspend,updateUserJwtSuspend.loginstill returnsNOT_INITIALIZED, now through the same helper.UninitializedManagers.kt): getters return"",falseor an empty map, everything else does nothing. For exampleOneSignal.User.onesignalIdreturns"", the same value the SDK already returns before the user is created.IN_PROGRESS, calls still block until it finishes, same as today.Not in this PR:
val user = OneSignal.User) stays the stand-in after init. Read the accessor again after init.initWithContextparams, separate change.Testing
Unit testing
Updated the "throws before init" tests to assert the calls are ignored and the accessors return stand-ins, and added coverage for the
FAILEDstate and the JWT listeners. Unit tests for core, notifications, in-app-messages and location, spotless, detekt and apiCheck pass.lintReleasereports 5 errors in files this PR does not touch (BackgroundManager,DatabaseCursor).Manual testing
Not done yet.
Affected code checklist
Checklist
Overview
Testing
Final pass
🤖 Generated with Claude Code