Repository navigation
fix: [SDK-5615] merge the anonymous user on composite login - #2816
Conversation
📊 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)31/31 touched executable lines covered (100.0% — requires ≥ 80%) |
|
Some findings:
|
|
Fixed in 0819022.
|
|
|
|
Double check this: If the backend only lists external_id, that body looks the same as your alias-conflict test and the switch-to-existing-user case fails. The manual "409, retry 202" result was on the previous commit. Can you rerun it on this one and paste the 409 body |
8adba35 to
22abbc6
Compare
|
Second pass is in 22abbc6.
|
|
Thanks for the note, worth checking. The switch-user 409 from Create User is: {
"errors": [
{
"code": "user-1",
"title": "Multiple existing Users found with provided set of Aliases",
"meta": {
"conflicting_aliases": {
"external_id": "<existing external id>",
"onesignal_id": "<anonymous onesignal_id sent on the request>"
}
}
}
]
}Create User adds |
|
|
Thanks, the create.go explanation makes sense. I'll do some more testing but if you get a chance, a quick emulator rerun of the external-ID-owned case on 22abbc6 would be nice to confirm. |
|
Reran the external-ID-owned case on 22abbc6. 409 body: {"errors":[{"code":"user-1","title":"Multiple existing Users found with provided set of Aliases","meta":{"conflicting_aliases":{"external_id":"ext5615rerun1","onesignal_id":"0a3e06fb-fce2-4e8c-9f59-a52ceec01c76"}}}]}The retry omitted |
ee2091a to
21b5a1c
Compare
Composite login creates the user directly, so data set on the anonymous user before login was left behind. It now sends the anonymous user's onesignal_id with the external ID, and Create User attaches the external ID to that user, matching what login(externalId) does through SetAlias. A 409 means the external ID already belongs to another user, so it retries without the onesignal_id. Co-authored-by: Cursor <cursoragent@cursor.com>
…ot be kept A non-conflict failure was dropped. Retry Create User without onesignal_id, and skip that retry when the 409 is an alias conflict. Co-authored-by: Cursor <cursoragent@cursor.com>
…he payload A 400 would fail the same way without the anonymous id. Conflict checks now go through OneSignalError, and only an alias conflict that does not name onesignal_id is final. Co-authored-by: Cursor <cursoragent@cursor.com>
Create User never returns user-2, and a handled 409 should not read as a failure. Co-authored-by: Cursor <cursoragent@cursor.com>
21b5a1c to
fc520cd
Compare
Description
One Line Summary
Composite login from an anonymous user now attaches the external ID to that user instead of creating a new one.
Details
Fixes SDK-5615. Stacked on #2815.
Motivation
Found in the 5.11.0 bug bash.
login(externalId)keeps the anonymous user's tags and push via SetAlias. Composite login sent one Create User with only the external ID, so it created a new user and left the anonymous data behind.Scope
When a login has profile fields, identity verification is off, and the anonymous user exists on the server,
LoginUserOperationExecutoradds itsonesignal_idto the same Create User request. Create User then attaches the new external ID to that user (201).If the external ID already belongs to another user, Create User returns 409
user-1withonesignal_idinconflicting_aliases. The SDK retries withoutonesignal_id. That switches users, same aslogin. A handled 409 also logs that switch, so the error response is not the outcome.Other merge failures:
onesignal_id.conflicting_aliasesnamesonesignal_id, or the body cannot be read.user-1is any alias clash, so the code alone is not enough.user-2is not a Create User response and is final. An alias-only 409 is final.Identity-only logins are unchanged (single SetAlias).
Note: the Create User docs only list
external_idas a requestidentityfield, though turbine acceptsonesignal_id.Testing
Unit testing
LoginUserOperationExecutorTestscovers the merge:onesignal_id.onesignal_id, an unreadable 409, and a 404 each retry without it.user-2do not retry.Manual testing
Emulator, demo app. The new-external-ID and identity-only rows are from the earlier session. The external-ID-owned row was rerun on
22abbc605(local SDK 5.10.2). This commit does not change that switch:user-1lists bothexternal_idandonesignal_id. Retry withoutonesignal_idreturns 202 on the existing userAnonymous user
0a3e06fb-fce2-4e8c-9f59-a52ceec01c76logged in with profile toext5615rerun1, already owned byc5322f8f-9885-46f1-be6c-9964e32a67b8. The 409 body:{"errors":[{"code":"user-1","title":"Multiple existing Users found with provided set of Aliases","meta":{"conflicting_aliases":{"external_id":"ext5615rerun1","onesignal_id":"0a3e06fb-fce2-4e8c-9f59-a52ceec01c76"}}}]}The follow-up Create User omitted
onesignal_idand returned 202 withonesignal_idc5322f8f-9885-46f1-be6c-9964e32a67b8.Affected code checklist
Checklist
Overview
Testing
Final pass