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 Report: Wrong signature for createMembership server side implementation #5676

Closed
2 tasks done
byawitz opened this issue Jun 7, 2023 · 4 comments · Fixed by appwrite/docs#386
Closed
2 tasks done
Assignees
Labels
bug Something isn't working product / docs Fixes and upgrades for the Appwrite Docs.

Comments

@byawitz
Copy link
Member

byawitz commented Jun 7, 2023

👟 Reproduction steps

  1. The docs for the createMembership() function doesn't match the function signature,
    https://appwrite.io/docs/server/teams?sdk=nodejs-default#teamsCreateMembership

In languages that utilize named parameters, it's not that of a problem, But in others, it can cause confusion.

  1. (Optional) Maybe it would be better to prioritize the required parameters over the optional ones.
    So this will become like this
 ->param('teamId', '', new UID(), 'Team ID.')
 ->param('roles', [], new ArrayList(new Key(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' roles are allowed, each 32 characters long.')
 ->param('url', '', fn($clients) => new Host($clients), 'URL to redirect the user back to your app from the invitation email.  Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.', false, ['clients']) 
 ->param('email', '', new Email(), 'Email of the new team member.', true)
 ->param('userId', '', new UID(), 'ID of the user to be added to a team.', true)
 ->param('phone', '', new Phone(), 'Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true)
 ->param('name', '', new Text(128), 'Name of the new team member. Max length: 128 chars.', true)
  1. (Optional) Omit the requirement of the URL parameter at all on the server side, see this 🚀 Feature: Omit the requirement of the URL parameter in server createMembership function #5675

👍 Expected behavior

Order in the docs and in the function should match.

👎 Actual Behavior

The order doesn't match and prioritizes optional fields over required ones.

🎲 Appwrite version

Version 1.3.x

💻 Operating system

Linux

🧱 Your Environment

No response

👀 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?

@byawitz byawitz added the bug Something isn't working label Jun 7, 2023
@byawitz byawitz changed the title 🐛 Bug Report: Wrong signature for createMembership server side implantation 🐛 Bug Report: Wrong signature for createMembership server side implementation Jun 7, 2023
@gewenyu99
Copy link

Interesting. @stnguyen90 The order of params in the specs match the order we input the params in the controller yah?

Sounds like we just need to update the order.

@gewenyu99
Copy link

@byawitz Thanks for brining this up!

@gewenyu99 gewenyu99 self-assigned this Jun 14, 2023
@joeyouss joeyouss added the product / docs Fixes and upgrades for the Appwrite Docs. label Jun 14, 2023
@bhagn
Copy link

bhagn commented Jul 15, 2023

I'm trying to use the server side sdk to create a team membership. But I get this error:

[Error] Type: TypeError
[Error] Message: {closure}(): Argument #3 ($userId) must be of type string, null given, called in /usr/src/code/vendor/utopia-php/framework/src/App.php on line 577
[Error] File: /usr/src/code/app/controllers/api/teams.php
[Error] Line: 396

But the docs don't mention anything about $userId parameter. Is this related to the Github issue here? The same issue with Phone and a few other optional params.

It accepts empty string but not null/None

@gewenyu99
Copy link

I'm trying to use the server side sdk to create a team membership. But I get this error:

[Error] Type: TypeError
[Error] Message: {closure}(): Argument #3 ($userId) must be of type string, null given, called in /usr/src/code/vendor/utopia-php/framework/src/App.php on line 577
[Error] File: /usr/src/code/app/controllers/api/teams.php
[Error] Line: 396

But the docs don't mention anything about $userId parameter. Is this related to the Github issue here? The same issue with Phone and a few other optional params.

It accepts empty string but not null/None

Which version are you running and which version of the docs are you looking at ;)

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 / docs Fixes and upgrades for the Appwrite Docs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants