Skip to content

fix: ignore login, logout and JWT calls before init instead of throwing - #2829

Draft
fadi-george wants to merge 1 commit into
mainfrom
fadi/noop-calls-before-init
Draft

fadi-george wants to merge 1 commit into
mainfrom
fadi/noop-calls-before-init

Conversation

@fadi-george

Copy link
Copy Markdown
Contributor

Description

One Line Summary

login, logout, updateUserJwt and the JWT listener calls log and return instead of throwing when init never started or failed.

Details

Motivation

A simpler alternative to the never-crash stack (#2800 to #2828) for the most common crash: calling login and friends before initWithContext, or after it failed. It reuses the existing init state and waitForInit instead of adding a new gate, deferred managers or a kill switch.

Scope

  • Before init (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.
  • The composite login still returns NOT_INITIALIZED, now through the same helper.
  • While init is IN_PROGRESS, calls still block until it finishes, same as today.
  • Cancellation still propagates.

Not in this PR:

  • Accessors (User, Notifications, InAppMessages, Location, Session) still throw before init. They need something to return, so they are a follow-up.
  • Nullable initWithContext params, separate change.
  • Calls dropped before init are not queued or replayed.

Testing

Unit testing

Updated the "throws before init" tests to assert the calls are ignored, and added coverage for the FAILED state and the JWT listeners. The full core unit test suite, spotless, detekt and apiCheck pass. lintRelease reports 5 errors in files this PR does not touch (BackgroundManager, DatabaseCursor).

Manual testing

Not done yet.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

Diff 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

  • OneSignalImp.kt: 12/21 touched executable lines (57.1%) (34 touched lines in diff)
    • 9 uncovered touched lines in this file

Overall (aggregate gate)

12/21 touched executable lines covered (57.1% — requires ≥ 80%)

Per-file detail (informational; gate is aggregate above):

  • OneSignalImp.kt: 57.1% (9 uncovered touched lines)

❌ Coverage Check Failed

Aggregate coverage on touched lines is 57.1% (minimum 80%).

📥 View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant