auth0/node-auth0

ManagementApiError.errorCode is undefined when trying to update the password of a user

alaczi opened this issue · 1 comments

alaczi commented

Checklist

  • I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

Using ManagementClient.users.update to change a user's password using the same password as the user's current password throws an error, but the errorCode property in the emitted error is undefined.
According to the definition of the error it can't be undefined.

Either change the definition of ManagementClientError.errorCode to allow undefined value or return set the errorCode to a valid string value.

Reproduction

1, create a user with a password
2, use the management api user's manager to update the user's password using the current password

    try {
      await managementClient.users.update(
        {
          id: "auth0|{your-user-id},
        },
        { password }
      );
    } catch (err) {
    // inspect the error
    }

3, inspect the error instance

Screenshot 2023-10-10 091822

Additional context

No response

node-auth0 version

4.0.1

Node.js version

20.8

Thanks for reporting, I can reproduce this and will look into how we want to proceed.