Skip to content

Avoid conflicts for Topcoder/ubahn users #46

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

Closed
maxceem opened this issue Dec 7, 2020 · 10 comments
Closed

Avoid conflicts for Topcoder/ubahn users #46

maxceem opened this issue Dec 7, 2020 · 10 comments
Labels
bug Something isn't working

Comments

@maxceem
Copy link
Contributor

maxceem commented Dec 7, 2020

Follow up from #23 (comment)

Sometimes we get conflict error during ensuring user exists in ubahn (when we create it):

image

It is possible the handle stored in your token was already used to create an ubahn user and associated with an userId other than the userId stored in your token.
So when the getUserId function tried to use the userId stored in your token to find an existing ubahn user, it got no record. It then attempted to create new ubahn user with the handle stored in your token, unsurprisingly, ending up conflict error.

Currently the data on Topcoder Dev are not reliable and stable, IMO. To avoid the conflict error, I would
suggest create a new tc member account with different username so you won't be messed up with any existing data.

Alternatively, You could find the conflicting ubhan user and correct its associated v3 userId(the externalId property) with the one in your user token.

@maxceem maxceem added the bug Something isn't working label Dec 7, 2020
@nkumar-topcoder
Copy link
Contributor

@sachin-maheshwari Can you please have a look at this please ?

@sachin-maheshwari
Copy link
Contributor

@nkumar-topcoder from the above description, it is not looking related to "new auth" or m2m core JS lib (for caching m2m token locally).

@maxceem
Copy link
Contributor Author

maxceem commented Jan 6, 2021

@callmekatootie sorry to disturb you again, but I guess only you could help us to find out the root of this issue quickly.

After we fixed issue #81 we can create new user in V5. But if we try to retrieve such users after, they are not found by v5.

Here is an example:

  • I have a new user maxceem20.
  • We created this user in V5 by calling POST /users and POST /users/${userId}/externalProfiles and got the next successfully responses:
     [2021-01-06T17:26:42.334Z] helper createUbahnUser DEBUG : response body: {"id":"c74c9888-94be-4295-92e0-f816f125486a","handle":"maxceem20","firstName":"Max","lastName":"20","createdBy":"NaN","updated":"2021-01-06T17:26:42.140Z","created":"2021-01-06T17:26:42.140Z","updatedBy":null}
     [2021-01-06T17:26:43.203Z] helper createUserExternalProfile DEBUG : response body: {"id":"0dd69d7d-4746-42d1-8c2f-d52f065cc4ef","organizationId":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","externalId":"88774202","userId":"c74c9888-94be-4295-92e0-f816f125486a","isInactive":false,"createdBy":"NaN","updated":"2021-01-06T17:26:42.820Z","created":"2021-01-06T17:26:42.820Z","updatedBy":null,"uri":null}
    
  • But, if we call endpoint GET https://api.topcoder-dev.com/v5/users?enrich=true&externalProfile.organizationId=36ed815b-3da1-49f1-a043-aaed0a4e81ad&externalProfile.externalId=88774202, this endpoint returns [] while it supposes to return a newly created user.
  • I tried to wait several minutes in case this is a caching issue, but it didn't help.

cc @nkumar-topcoder

@callmekatootie
Copy link
Collaborator

@maxceem This is an issue with the ubahn api - I will resolve this on priority

@callmekatootie
Copy link
Collaborator

@maxceem Could you kindly check now. Let me know if you are still facing an issue

@maxceem
Copy link
Contributor Author

maxceem commented Jan 7, 2021

Thanks, @callmekatootie. It works for new users which is great. The only thing for the users we created previously - it doesn't return them.

I've tried with a new user maxceem19.
It was created successfully:

[2021-01-07T10:14:38.643Z] helper createUbahnUser DEBUG : response body: {"id":"af6de072-70aa-4c28-866f-2f7223ec1d47","handle":"maxceem19","firstName":"Max","lastName":"19","createdBy":"NaN","updated":"2021-01-07T10:14:36.907Z","created":"2021-01-07T10:14:36.907Z","updatedBy":null}
[2021-01-07T10:14:39.371Z] helper createUserExternalProfile DEBUG : response body: {"id":"0c06e5a2-d406-467f-bd08-121a182fd349","organizationId":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","externalId":"88771452","userId":"af6de072-70aa-4c28-866f-2f7223ec1d47","isInactive":false,"createdBy":"NaN","updated":"2021-01-07T10:14:39.182Z","created":"2021-01-07T10:14:39.182Z","updatedBy":null,"uri":null}

And it is retuned:

[2021-01-07T10:15:28.367Z] helper getUserIds DEBUG : response body: [{"lastName":"19","updatedBy":null,"created":"2021-01-07T10:14:36.907Z","groups":[],"handle":"maxceem19","firstName":"Max","externalProfiles":[{"organizationId":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","updatedBy":null,"isInactive":false,"createdBy":"NaN","created":"2021-01-07T10:14:39.182Z","organization":{"updatedBy":"tc-Copilot","createdBy":"tc-Copilot","created":"2020-05-05T11:01:31.334Z","name":"Topcoder","skillProviders":[{"organizationId":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","updatedBy":"tc-Copilot","createdBy":"tc-Copilot","created":"2020-05-05T11:01:31.334Z","skillProviderId":"7637ae1a-3b7c-44eb-a5ed-10ea02f1885d","id":"909da0a2-3c46-4ec9-9a6d-f6f3829fa07a","updated":"2020-05-05T11:02:10.574Z"}],"id":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","updated":"2020-05-05T11:02:10.574Z"},"externalId":"88771452","id":"0c06e5a2-d406-467f-bd08-121a182fd349","userId":"af6de072-70aa-4c28-866f-2f7223ec1d47","updated":"2021-01-07T10:14:39.182Z","uri":null}],"createdBy":"NaN","id":"af6de072-70aa-4c28-866f-2f7223ec1d47","updated":"2021-01-07T10:14:36.907Z"}]

For the user maxceem20 I've created previously, it still doesn't return it.

This request returns [].

GET https://api.topcoder-dev.com/v5/users?enrich=true&externalProfile.organizationId=36ed815b-3da1-49f1-a043-aaed0a4e81ad&externalProfile.externalId=88774202

But if I try to create this user again, I get a Conflict.

@callmekatootie
Copy link
Collaborator

Makes sense. I have currently requested the devops team to run the data sync script - should take about 45 mins. Will let you know when it completes.

@callmekatootie
Copy link
Collaborator

@maxceem can you try now. We have synced the data b/w the db and elasticsearch

@maxceem
Copy link
Contributor Author

maxceem commented Jan 8, 2021

Thank you, @callmekatootie. Works perfectly now.

User maxceem20 is returned too:

[2021-01-08T08:11:34.364Z] helper getUserIds DEBUG : response body: [{"lastName":"20","updatedBy":"tcAdmin","created":"2021-01-06T17:26:42.140Z","handle":"maxceem20","firstName":"Max","externalProfiles":[{"organizationId":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","updatedBy":"tcAdmin","createdBy":"NaN","isInactive":false,"created":"2021-01-06T17:26:42.820Z","organization":{"updatedBy":"tc-Copilot","createdBy":"tc-Copilot","created":"2020-05-05T11:01:31.334Z","name":"Topcoder","skillProviders":[{"organizationId":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","updatedBy":"tc-Copilot","createdBy":"tc-Copilot","created":"2020-05-05T11:01:31.334Z","skillProviderId":"7637ae1a-3b7c-44eb-a5ed-10ea02f1885d","id":"909da0a2-3c46-4ec9-9a6d-f6f3829fa07a","updated":"2020-05-05T11:02:10.574Z"}],"id":"36ed815b-3da1-49f1-a043-aaed0a4e81ad","updated":"2020-05-05T11:02:10.574Z"},"externalId":"88774202","id":"0dd69d7d-4746-42d1-8c2f-d52f065cc4ef","uri":null,"updated":"2021-01-06T17:26:42.820Z","userId":"c74c9888-94be-4295-92e0-f816f125486a"}],"createdBy":"NaN","id":"c74c9888-94be-4295-92e0-f816f125486a","updated":"2021-01-06T17:26:42.140Z"}]

@maxceem
Copy link
Contributor Author

maxceem commented Jan 8, 2021

I think we found the root cause of this issue and it's all covered now, so I'm closing it.

@maxceem maxceem closed this as completed Jan 8, 2021
@maxceem maxceem added this to the v1.0 - Initial Launch milestone Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants