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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: Unable to delete team membership from user profile if the team doesn't exist #5914

Closed
2 tasks done
vlohar08 opened this issue Jul 31, 2023 · 8 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.

Comments

@vlohar08
Copy link

馃憻 Reproduction steps

  1. Add any auth user to any team.
  2. Now delete the team without removing the user from it.
  3. Now go to the user teams page and try to delete the membership.
    You will get this error - The Requested Team Invitation Could not be found.

馃憤 Expected behavior

  • If a team is deleted then the membership of that team should be removed from the user profile of all the members of that team.
  • Or at least, it should allow us to delete the membership even if it doesn't exist without any error.

馃憥 Actual Behavior

  • If the team is deleted without removing the membership from the user profile then the team name is changed to n/a and the thumbnail stops loading.
  • If you try to delete the membership manually then you will get an error - The Requested Team Invitation Could not be found.

image

馃幉 Appwrite version

Version 1.3.x

馃捇 Operating system

Linux

馃П Your Environment

Appwrite Version - 1.3.8
Self-hosted on Digital Ocean using Marketplace Image

馃憖 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

馃彚 Have you read the Code of Conduct?

@vlohar08 vlohar08 added the bug Something isn't working label Jul 31, 2023
@safwanyp
Copy link
Contributor

safwanyp commented Aug 1, 2023

Never tried doing this and I can see why this happens. I was going to suggest a custom function that triggers when teams.*.delete occurs, but it would cause the same issue I think.

Interesting to say the least. Gonna take a small look into the code.

@safwanyp
Copy link
Contributor

safwanyp commented Aug 1, 2023

Alright so looking at the calls being made, it's pretty clear why this happens.

Deleting a membership makes a DELETE request to /v1/teams/:teamId/memberships/:membershipId which would instantly be a mistake if the team does not exist, as :teamId would be non-existent. A TEAM_NOT_FOUND exception is thrown in the code as well.

I think the best way to fix this would be to implement deletion of all memberships in a team, when a team is deleted. But it seems like this is already being done. Now I'm even more intrigued lol

Edit: It does look like the membership isn't "unlinked" from the user though. So that would explain the issue you're facing. Gonna dive deeper

@vlohar08
Copy link
Author

vlohar08 commented Aug 1, 2023

Yes, You're right!
I am not using the team's feature, and I just reported this. I feel if this happens then either you should automatically fix this or at least allow me to manually delete the memberships.

Without it, the membership will be forever present in the user details with the name n/a and no thumbnail. It is a dead end.

@christyjacob4 christyjacob4 self-assigned this Aug 1, 2023
@christyjacob4
Copy link
Member

@vlohar08 thank you for raising this. We'll investigate this and share some more details :)

@safwanyp
Copy link
Contributor

safwanyp commented Aug 1, 2023

Hi Appwrite team. Can I be assigned to make a PR for this issue? I have fixed it on a local dev environment by adding the membership attribute to the allowed attributes list, and running a small delete function on the user.

@christyjacob4
Copy link
Member

@safwanyp sure go ahead 馃槃 I'll assign it to you

@stnguyen90
Copy link
Contributor

Actually, I'm going to close this as a duplicate of #5517

@stnguyen90 stnguyen90 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2023
@safwanyp
Copy link
Contributor

safwanyp commented Aug 1, 2023

@safwanyp sure go ahead 馃槃 I'll assign it to you

Appreciate it Christy! Making a PR now 馃榿

@stnguyen90 stnguyen90 added the product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services. label Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / auth Fixes and upgrades for the Appwrite Auth / Users / Teams services.
Projects
None yet
Development

No branches or pull requests

4 participants