fix: [SDK-5014] omit local subscription IDs from the create user request - #1484
Conversation
|
@claude review once |
How to test this manually (updated for the logout path)The branch includes a repro harness in Background: the bug needs a push subscription whose ID is still a Setup
See the bug (without the fix)
Confirm the fix
Note: an anonymous create user request with no identity and no subscriptions (the |
|
maybe explore a change like this in LoginManger: |
|
@fadi-george @sherwinski is this something going live in an upcoming update? |
ReviewApproved — this is the right minimal fix for SDK-5014. The root-cause analysis checks out: The executor guard is well placed:
The two new unit tests cover both paths, CI is green, and the manual repro steps in the PR comment are clear. Non-blocking follow-ups (optional)
None of these block merge. Ship it. |
|
I did this check for logout:
await OneSignal.login('logout-repro-user');
const model = await OneSignal._coreDirector._getPushSubscriptionModel();
model._setProperty('id', `local-${crypto.randomUUID()}`, 1);
await OneSignal.logout();
{ "identity": {}, "subscriptions": [] }
But at least reloading recovers from it. |
|
Hey @dombartenope, this is now live in v160610 🚀 |
Description
1 Line Summary
Stop the SDK from sending
local-*placeholder subscription IDs in the Create User request, which the backend rejects as invalid UUIDs.Details
The
login()andlogout()flows enqueue aTransferSubscriptionOperationwith the current push subscription model ID. That ID can still be alocal-*placeholder when the create-subscription operation did not complete first (for example, after a network failure dropped the pending operations)._canStartExecuteblocks such a transfer op from starting on its own, butOperationRepo._getGroupableOperationsdoes not check_canStartExecutefor grouped operations. ALoginUserOperationwith the same comparison key groups the transfer op, and the transfer branch inLoginUserOperationExecutorcopied the local ID into the payload as{"id": "local-..."}. The backend rejects the request withuuid: incorrect UUID length 42.The failure then persists: the 400 maps to
FailPauseOpRepo, so the operations re-queue, persist in IndexedDB, and fail again on every page load. Affected users stay unsubscribed until they clear site data.The fix changes the transfer branch for a local subscription ID. A transfer grouped with a create op keeps the create data and adds no
id. A lone transfer op rebuilds the subscription data from the model inSubscriptionModelStore, again with noid, so the backend creates the subscription and ID translation still runs. A model with no token is skipped, because the store listener never sends a token-less subscription as enabled and the model self-heals on the next subscribe. A create user request that ends with no identity and no subscriptions is dropped (FailNoretry) instead of sent, which matches the Android SDK. Users who are stuck today recover on their next page load because the persisted login operation now sends a valid payload.The size limit for
OneSignalSDK.page.es6.jsmoves from 42.7 kB to 42.78 kB; the new branch pushed the gzip size 67 bytes over the old limit.The manual repro harness used during review is not part of the final diff. Commit
9a0f42eon this branch has the last version of it, and the PR comment "How to test this manually" has the steps.Systems Affected
Validation
Tests
Info
5 new unit tests in
LoginUserOperationExecutor.test.ts. Before the fix, the first test reproduced the exact invalid payload from the customer report (subscriptions: [{"id": "local-..."}]). The other tests cover the create-plus-transfer group, the rebuild from the model on logout, the token-less model, and the dropped empty payload. All pass after the fix, along with the full suite,vp check, andvp run build:prod.Checklist
Programming Checklist
Interfaces:
Functions:
Typescript:
Other:
elem of arraysyntax. PreferforEachor usemapcontextif possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.contextScreenshots
Info
Not needed: the change affects a network payload with no UI impact. The unit tests assert the payload contents.
Checklist
Related Tickets
SDK-5014