Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: One or more Aliases claimed by another User #714

Open
3 tasks done
jt274 opened this issue Aug 25, 2023 · 23 comments
Open
3 tasks done

[Bug]: One or more Aliases claimed by another User #714

jt274 opened this issue Aug 25, 2023 · 23 comments
Labels

Comments

@jt274
Copy link

jt274 commented Aug 25, 2023

What happened?

v5.0.0 throws the error after following the migration guide and using an existing user. App uninstall/reinstall does not fix the issue. Issue did not occur on Android emulator using User1 account, but did occur on physical device using User2 account.

The docs specifically state that if the user already exists when logging in, the user will be updated. If the user does not exist, they will be created.

After throwing the error, it repeatedly retries in an infinite loop.

OneSignal.initialize('APP_ID');

await OneSignal.login('USER_ID');

await OneSignal.User.pushSubscription.optIn();

Additionally, the following error is thrown:

MissingPluginException(No implementation found for method OneSignal#optIn on channel OneSignal#pushsubscription)

Steps to reproduce?

1. Upgrade onesignal_flutter from 3.5.1 to 5.0.0 using the posted migration guide.
2. Run app as logged in user

What did you expect to happen?

User should be updated according to external_id. Any anonymous user should be merged with existing user according to external_id.

OneSignal Flutter SDK version

5.0.0

Which platform(s) are affected?

  • iOS
  • Android

Relevant log output

D/OneSignal(22407): [OpRepo] IdentityOperationExecutor(operations: [{"name":"set-alias","appId":"APP_ID","onesignalId":"ONESIGNAL_ID","label":"external_id","value":"USER_ID"}])
D/OneSignal(22407): [DefaultDispatcher-worker-2] HttpClient: PATCH apps/APP_ID/users/by/onesignal_id/ONESIGNAL_ID/identity - {"identity":{"external_id":"USER_ID"}}
D/OneSignal(22407): [DefaultDispatcher-worker-10] HttpClient: PATCH apps/APP_ID/users/by/onesignal_id/ONESIGNAL_ID/identity - FAILED STATUS: 409
W/OneSignal(22407): [DefaultDispatcher-worker-10] HttpClient: PATCH RECEIVED JSON: {"errors":[{"code":"user-2","title":"One or more Aliases claimed by another User",
D/OneSignal(22407): [DefaultDispatcher-worker-10] HttpClient: POST apps/APP_ID/users - FAILED STATUS: 500
W/OneSignal(22407): [DefaultDispatcher-worker-10] HttpClient: POST RECEIVED JSON: 
D/OneSignal(22407): [OpRepo] OperationRepo: execute response = FAIL_RETRY

Code of Conduct

  • I agree to follow this project's Code of Conduct
@faccioliandrea
Copy link

same issue

@emawby emawby added the Bug label Aug 25, 2023
@emawby
Copy link
Contributor

emawby commented Aug 25, 2023

@jt274 Thank you for reporting we are investigating both issues. For the login issue how many devices have used the User1 external_id. There is a subscription limit of 20 subscriptions that you might be hitting when testing and the error message might misleading

@jt274
Copy link
Author

jt274 commented Aug 25, 2023

@emawby
There has only been one (maybe two at most) device using that account. However it has run both debug and production versions of the app. So maybe it would cause an issue if the app is reinstalled more than once and it sees it as a new device each time?

@emawby
Copy link
Contributor

emawby commented Aug 25, 2023

@jt274 Yes a uninstall/reinstall counts as a new subscription (new push token) so that may be the issue, but the error message should indicate that subscription limit was hit in that case. It looks like the 409 is expected, but the SDK should be handling it for you. The 500 error in the log is likely the root cause of the problem. Are you able to share the request of the POST apps/APP_ID/users call that got the 500 error?

@jt274
Copy link
Author

jt274 commented Aug 25, 2023

@emawby
So you are saying the SDK should handle it by, for example, deleting old subscriptions and properly updating the user?

Are you wanting the app ID and user's onesignal ID (the parts I redacted)?

@jt274
Copy link
Author

jt274 commented Aug 27, 2023

@emawby

If I search the external ID in the onesignal dashboard, it pulls up 6 subscriptions matching the external ID, all associated with one onesignal ID.

I believe this is the 500 error you're referring to:

[DefaultDispatcher-worker-3] HttpClient: POST apps/APP_ID/users - {"identity":{"external_id":"USER_ID"},"subscriptions":[{"id":"ONESIGNAL_ID","token":"PUSH_TOKEN","enabled":true,"notification_types":1},{"type":"Email","token":"[email protected]","enabled":true,"notification_types":1,"sdk":"050000","device_model":"SM-G981V","device_os":"12","rooted":false,"net_type":0,"carrier":"US  Mobile","app_version":"44"}]}

@jt274
Copy link
Author

jt274 commented Sep 1, 2023

@emawby

The app is trying to use the PATCH command to update the user alias using the onesignal_id alias label like so:

PATCH apps/APP_ID/users/by/onesignal_id/ONESIGNAL_USER_ID/identity

However, it returns the 409 error because the external id is already taken by another onesignal user. I believe it is supposed to update the already existing onesignal user by issuing the PATCH command using the external_id alias label like this instead:

PATCH apps/APP_ID/users/by/external_id/USER_ID/identity

This is according to the docs here: https://documentation.onesignal.com/reference/create-alias

The logged in user should then be linked to the onesignal_id associated with the provided external_id. Is that correct?

@jt274
Copy link
Author

jt274 commented Sep 12, 2023

Although I have not done extensive testing, this issue appears to be resolved on the back end. @emawby can you confirm?

@RogerBrusamarello
Copy link

any updates here?

@ChoyCheeWei
Copy link

any updates on this?

@vasilich6107
Copy link

@emawby any updates?

@nan-li
Copy link
Contributor

nan-li commented Feb 7, 2024

Hi @jt274 sorry for the delayed response.

There have been numerous backend fixes since August, so it may have been fixed. Are you still seeing this 500 response anymore?

I'll explain more about how the SDK handles the 409 response:

  1. When you call login to an existing user, this 409 response is expected. The reason is we are trying to attach that external_id to the local data in the SDK, since that user may be brand new. If the user is not new, this attempt to attach the external_id fails.
  2. We added a new log in recent releases to say the SDK is handling the response, for improved clarity.
  3. We clear the local state and fetch that existing user's data from the backend and populate the local data with that state.

@nan-li
Copy link
Contributor

nan-li commented Feb 7, 2024

Hi @RogerBrusamarello @ChoyCheeWei @vasilich6107, please tell me more about what you are running into and what version of the SDK you are using.

@gitananun
Copy link

gitananun commented Mar 2, 2024

Having the same issue.

errors = ( { code = "user-2"; meta = { "external_id" = "..."; }; title = "One or more Aliases claimed by another User"; } ); httpStatusCode = 409;

@Yurockkk
Copy link

facing the same issue... any updates?

@ArthurMiroslavsky
Copy link

ArthurMiroslavsky commented Jul 17, 2024

Same issue(( (v16)

@HarunKilic
Copy link

I do also have issue where same user signs in from another device. It throws the error.
Tried to remove the subscriptions (all of them) and getting this error now: "One or more Aliases claimed by another User", even tho subscriptions are empty.

@Marco2686
Copy link

Same here, tryed to delete the aliase with postman but get

{ "errors": [ { "title": "No subscription with alias (alias: my_alias) found" } ] }

@KevinToala
Copy link

Same error

@lookmanrays
Copy link

The same issue

@nan-li
Copy link
Contributor

nan-li commented Nov 12, 2024

Hi, please add more details about your issue. Please explain in detail beyond a one liner.

As I explained above, the SDK handles 409 errors:

I'll explain more about how the SDK handles the 409 response:

  1. When you call login to an existing user, this 409 response is expected. The reason is we are trying to attach that external_id to the local data in the SDK, since that user may be brand new. If the user is not new, this attempt to attach the external_id fails.
  2. We added a new log in recent releases to say the SDK is handling the response, for improved clarity.
  3. We clear the local state and fetch that existing user's data from the backend and populate the local data with that state.

@marshall86
Copy link

this issue is still there. A user can easily have multiple devices or can change a device at some point and despite having an entry in the CRM it won't be possible to have said entry with the external_id correctly set.

"A user is a new concept which is meant to represent your end-user. A user has zero or more subscriptions and can be uniquely identified by one or more aliases. In addition to subscriptions, a user can have data tags which allows for user attribution." from your documentation

@IZSkiSurfer
Copy link

IZSkiSurfer commented Feb 12, 2025

I'm facing the exact same problem. After deleting a few entries with that externalId I was at least able to get the "new" device displayed as "subscribed" in the subscriptions page... But the 409 was popping up also.

Btw. I just saw that this is the Flutter repository... I use react-native and it's the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests