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

"getUser()" method returning an array, mismatch with TS definitions #590

Closed
danawoodman opened this issue Mar 10, 2021 · 6 comments
Closed

Comments

@danawoodman
Copy link

danawoodman commented Mar 10, 2021

Describe the problem

As request in #572 from my comment here I'm reporting what I think is a mismatch in the TS definitions and the Management response for getUser.

It appears getUser() is returning an array but the TS definitions are expecting an object. I would also assume that the method should return a single object

What was the expected behavior?

Should return a single object for getUser as name is singular not plural.

Reproduction

image

image

Logging out the response from getUser(id) returns an array of user objects.

Environment

  • Version of this library used: 2.33.0
  • Which framework are you using, if applicable: Sapper/Svelte
  • Other modules/plugins/libraries that might be involved: Express
  • Any other relevant information you think would be useful: 🤷‍♂️
@davidpatrick davidpatrick added the needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue label Mar 10, 2021
@davidpatrick
Copy link
Contributor

davidpatrick commented Mar 10, 2021

Hey @danawoodman thanks for opening the issue. It sounds like getUser(id) is using http://auth0.com/docs/api/management/v2/#!/Users/get_users with the id param, and you were expecting it to use http://auth0.com/docs/api/management/v2/#!/Users/get_users_by_id

We will need to investigate this a little bit to decide on a solution. If we change what getUser(id) returns, we can break current usage of it, so we may need to introduce a getUserById(id) that matches to get_users_by_id, and document each method clearly to illustrate which endpoint they are hitting.

Thanks again for calling this out, we will have a look.

@danawoodman
Copy link
Author

@davidpatrick Thanks, yeah that is what I was expecting. A getUserById would make sense to prevent a breaking change. Maybe getUesr could be deprecated as well if so?

@danawoodman
Copy link
Author

danawoodman commented Mar 11, 2021

Just noticed that getUserByEmail also returns an array 😿

EDIT: Nevermind it is getUsersByEmail, ignore me here

@davidpatrick
Copy link
Contributor

davidpatrick commented Mar 24, 2021

@danawoodman I'm not seeing a getUserByEmail just a getUsersByEmail

@danawoodman
Copy link
Author

@davidpatrick ahh you're right, must have been a hard day when I posted that! 🤦

@davidpatrick davidpatrick removed the needs investigation An issue that has more questions to answer or otherwise needs work to fully understand the issue label Mar 24, 2021
@davidpatrick
Copy link
Contributor

@danawoodman just tested this out, and the getUser method does return the single user object. I think the problem is that you are passing in the id and not the object with id as specified in the documentation

 * management.getUser({ id: USER_ID }, function (err, user) {
 *   console.log(user);
 * });

I still see the confusion of this method though. The problem with changing it is that we could have users doing management.users.get() to retrieve all users or even management.getUser() to retrieve all users. I will add it to our discovery work for the next major.

Thanks again for giving the confusion some visibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants