Skip to content

Commit b445a01

Browse files
committed
Fix FAIL_UNAUTHORIZED re-queue loop when IV is disabled
Gate the FAIL_UNAUTHORIZED re-queue path on useIdentityVerification == true. When IV is OFF, hasValidJwtIfRequired() always returns true so re-queued ops were immediately eligible, creating a ~200ms infinite retry loop. Now IV-OFF treats FAIL_UNAUTHORIZED the same as FAIL_NORETRY (drop + wake waiters). Also fix Operation.externalId KDoc: subclass constructors set this field, not IOperationRepo at enqueue time. Made-with: Cursor
1 parent a292935 commit b445a01

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/operations/Operation.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ abstract class Operation(name: String) : Model() {
1919
/**
2020
* The external ID of the user this operation belongs to. Used by [IOperationRepo] to look up
2121
* the correct JWT when identity verification is enabled, and to gate anonymous operations.
22-
* Stamped automatically by [IOperationRepo] at enqueue time from the current identity model
23-
* when not already set by the concrete operation's constructor.
22+
* Must be set by each concrete [Operation] subclass constructor — typically from the current
23+
* identity model's externalId at the time the operation is created.
2424
*/
2525
var externalId: String?
2626
get() = getOptStringProperty(::externalId.name)

OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/operations/impl/OperationRepo.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ internal class OperationRepo(
284284
ops.forEach { it.waiter?.wake(true) }
285285
}
286286
ExecutionResult.FAIL_UNAUTHORIZED -> {
287+
val identityVerificationEnabled = _configModelStore.model.useIdentityVerification == true
287288
val externalId = startingOp.operation.externalId
288-
if (externalId != null) {
289+
if (identityVerificationEnabled && externalId != null) {
289290
_jwtTokenStore.invalidateJwt(externalId)
290291
Logging.warn("Operation execution failed with 401 Unauthorized, JWT invalidated for user: $externalId. Operations re-queued.")
291292
// Unblock any enqueueAndWait callers so loginSuspend doesn't hang.

0 commit comments

Comments
 (0)