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

API error 0 when calling setDiscordRoles with empty role list #2375

Closed
Sylensky opened this issue Aug 21, 2021 · 16 comments
Closed

API error 0 when calling setDiscordRoles with empty role list #2375

Sylensky opened this issue Aug 21, 2021 · 16 comments
Labels
Milestone

Comments

@Sylensky
Copy link

Describe the issue
I have a very specific case of an group sync issue within the latest version.
On my ingame server i run discordsrv which syncs my ranks to my discord and from there nameless link fowards the role changes to my v2pr10 nameless homepage.
Thing is role remove and add requests are happening so fast that i think the homepage drops one event and returns the api error 0. For example: mc -> discord: role has been set, dc removes old role and adds new role. discord -> homepage: notices role remove event - executes it and drops the newly assigned role change. Interestingly manual(slow) reassigning a role on discord makes the syncing work properly.
Atleast thats what i observed down below on the logs of nameless link. Furthermore i didn't noticed any logs related to an issue with assigning the role.

To Reproduce
Steps to reproduce the behaviour:

  1. setup group sync on nameless
  2. setup the nameless link bot
  3. setup discordsrv on the mc server
  4. assign a new role to a player ingame and check discord logs and nameless-link logs
  5. observe the role not getting assigned instead the default role is shown for that player

Expected behaviour
properly synced group

Screenshots
image

NamelessMC version (from StaffCP -> Overview)
Running NamelessMC version 2.0.0-pr10
PHP 7.4.21
PHP GD 7.4.21
PHP mbstring 7.4.21
PHP PDO 7.4.21
PHP cURL 7.4.21
PHP XML 7.4.21
PHP EXIF 7.4.21
PHP MySQL
core/config.php Writable
Cache Writable
Template Cache Writable

Additional information
Previously i was talking to derkades to embed a queue like system for role changes to improve race condition handling. Maybe this would also help in this particular case.

@tadhgboyle
Copy link
Member

@Derkades

@Derkades
Copy link
Member

Derkades commented Aug 22, 2021

Previously i was talking to derkades to embed a queue like system for role changes to improve race condition handling. Maybe this would also help in this particular case.

This has already been implemented: NamelessMC/Nameless-Link#207. Weren't you running this version during your tests? You should see the "checking user {} guild {} with {} items left in queue" at most once every two seconds.

@Sylensky
Copy link
Author

Sylensky commented Aug 22, 2021

Yes i was using the queue system already but you told me to create a ticket on nameless itself as the issue in the screenshot seems to be a homepage issue rather then a nameless link issue.

@Derkades
Copy link
Member

Yes, but since you are using the queue system I don't think this is a "race condition" or in any way related to role changes in quick succession. What happens if you only cause one change role event?

@Sylensky
Copy link
Author

If i remove a role from a user on discord and assign a new one it works. That made me think it works when executed slowly enough.

@Derkades
Copy link
Member

Can you check if the queue works, so if the "checking user" messages are at least 2 seconds apart?

@Sylensky
Copy link
Author

Ok i did check if they are apart and that does look fine. Apparently during testing i noticed the API error 0 is actually occuring when the role of the user on discord got removed - so he has no roles at all. Below is what the link logs say:
image

The logs when i assign him a new role look like this:
image

@Sylensky
Copy link
Author

Additionally to provide more information i did some further testing. I did add a role to a player ingame via luckperms editor which triggers discordsrv to update the users role in discord which also triggers nameless link to update the users group on the homepage:
image

From the logs it looks fine that the rank got assigned but on the group sync logs there is only the remove event listed:
image
Unfortunately i couldnt find anything else in the logs.

@Derkades Derkades changed the title Group Sync race condition API error 0 when calling setDiscordRoles with empty role list Aug 23, 2021
@Derkades Derkades added the bug label Aug 23, 2021
@Derkades Derkades added this to the 2.0.0-pr11 milestone Aug 23, 2021
@samerton samerton modified the milestones: 2.0.0-pr11, 2.0.0-pr12 Aug 24, 2021
@Derkades
Copy link
Member

Cannot reproduce myself, this is what happens when I add one role and remove that role:

[JDA [1 / 2] MainWS-ReadThread] INFO Group sync discord->website - Received guild member role add event for 183954832485253121 in 776921071953772615, adding to queue
[pool-2-thread-1] INFO Group sync discord->website - Checking user 183954832485253121 guild 776921071953772615 with 0 items left in queue
[pool-2-thread-1] INFO Group sync discord->website - Sucessfully sent roles to website: guildid=776921071953772615 userid=183954832485253121 roles=[785970326030778408]
[JDA [1 / 2] MainWS-ReadThread] INFO Group sync discord->website - Received guild member role remove event for 183954832485253121 in 776921071953772615, adding to queue
[pool-2-thread-1] INFO Group sync discord->website - Checking user 183954832485253121 guild 776921071953772615 with 0 items left in queue
[pool-2-thread-1] INFO Group sync discord->website - Sucessfully sent roles to website: guildid=776921071953772615 userid=183954832485253121 roles=[]

@Sylensky
Copy link
Author

Did you add roles "by hand" or with a third party accessing discord?

@Derkades
Copy link
Member

Derkades commented Aug 27, 2021

By hand. While testing a bit more I did find a new issue: #2384. I'm not getting it to produce API error 0 though.

@Sylensky
Copy link
Author

Sylensky commented Aug 27, 2021

Can you try it out with a spigot server and the discordsrv plugin? Iam very confident that you will get there the api error 0.
If you need details about discordsrv hit me up on discord.

@Derkades
Copy link
Member

@samerton is it possible to make the API endpoint provide more useful information other than just API error 0 without meta?

partydragen added a commit that referenced this issue Aug 27, 2021
@partydragen
Copy link
Member

The setDiscordRoles have been completely rewritten and have tested alot so it looks like it work now

As for the log that was a bug too, as added value did not register the group successfully
I can't see any reason of this error to happen, atleast not with this rewrite

@Derkades
Copy link
Member

It works for me

@Sylensky
Copy link
Author

I can confirm that this issue is resolved with the revamp of the endpoint.

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

5 participants