Back

BUG: teams.listMemberships returns 404 when team exists but using query to filter users

  • 0
  • Teams
  • Flutter
  • Cloud
ggsotillo
17 Jul, 2023, 23:32

using sdk for Flutter. my code:

Future<models.Membership?> getMembership(String teamId, String userId) async { try { final models.MembershipList list = await teams.listMemberships( teamId: teamId, queries: [ Query.equal('userId', userId) ] ); return list.total > 0 ? list.memberships[0] : null; } catch (e) { print("ERROR getMembership: $e"); return null; } }

expected: 200 OK with MembershipList.total = 0 actual: AppwriteException: team_not_found, Team with the requested ID could not be found. (404). server version: Cloud (1.1.2). SDK Flutter 8.1.0 <#1102936099745177700>

TL;DR
Users are experiencing a 404 error when using the `teams.listMemberships` API endpoint to filter users in a team. Some users argue that this is expected behavior since the endpoint is for listing memberships, not teams. However, another user needs to validate the roles by returning the membership, even if the user is not part of the team. One potential solution is to check if `list.total` is greater than 0 before returning the membership. Additionally, there is a mention of a code fix in the source (master branch) that may have resolved the issue in version 1.1.2. It is suggested to confirm this
ggsotillo
18 Jul, 2023, 00:27

according to the source (master branch) probably was resolved later 1.1.2. could anyone confirm this?

Drake
18 Jul, 2023, 01:09

make sure to use 3 backticks when formatting multiline code

what happens if you run teams.list()?

ggsotillo
18 Jul, 2023, 02:11

Returns $.total=0 if the user not belongs to the group (great). But I need to return the membership to validate the roles

Drake
18 Jul, 2023, 02:11

So if they aren't in the team, it'll return 404. That's expected

ggsotillo
18 Jul, 2023, 02:28

I agree to be disagree. The name of the endpoint is membership, no team. Membership is a sub resource of team. So the right answer should be total=0 because is returning a list of memberships

ggsotillo
18 Jul, 2023, 02:29

Like team.list return total=0 too

Drake
18 Jul, 2023, 02:42

Yes, because the user isn't in any teams

Drake
18 Jul, 2023, 02:43

The API lists the memberships of a team, but the team doesn't exist

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more