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

[SDK-1405] Added support for new generic error details #1084

Merged
merged 4 commits into from
Mar 27, 2020

Conversation

stevehobbsdev
Copy link
Contributor

@stevehobbsdev stevehobbsdev commented Mar 10, 2020

Changes

This PR adds support for new "blocked_reasons" error type, which includes more detail behind why a user has been blocked.

The details are surfaced in the error object as follows:

{
  code: 'blocked_user',
  description: 'Blocked user.',
  errorDetails: {
    codes: [ 'reason-1', 'reason-2' ],
    details: {
      'reason-1': {
        timestamp: 123786498
      },
      'reason-2': {
        timestamp: 127836389
      }
    }
  } 
}

References

Support for this was generated from an internal service desk ticket.

Testing

  • This change adds unit test coverage
  • This change adds integration test coverage

Checklist

@stevehobbsdev stevehobbsdev added this to the vNext milestone Mar 10, 2020
@stevehobbsdev stevehobbsdev changed the title [SDK-1405Added support for new 'blocked_reasons' error type [SDK-1405] Added support for new 'blocked_reasons' error type Mar 10, 2020
@ademartini
Copy link

I think this looks good. @abbaspour, you had mentioned needing a new callback here?

@stevehobbsdev stevehobbsdev marked this pull request as ready for review March 12, 2020 12:01
@stevehobbsdev stevehobbsdev requested a review from a team March 12, 2020 12:01
@adamjmcgrath adamjmcgrath self-assigned this Mar 17, 2020
@adamjmcgrath adamjmcgrath requested review from adamjmcgrath and removed request for a team March 17, 2020 09:57
adamjmcgrath
adamjmcgrath previously approved these changes Mar 17, 2020
Copy link
Contributor

@adamjmcgrath adamjmcgrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@stevehobbsdev
Copy link
Contributor Author

Thanks @adamjmcgrath. I've just read this is due a further change so I will hold off merging for now. Will need another review once those changes are made.

@@ -58,6 +59,17 @@ function wrapCallback(cb, options) {
errObj.error_description = errObj.description;
}

if (
errObj.code === 'blocked_user' &&
Copy link

@madsharm madsharm Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A question - do we need to have this hardcoded check here on 'blocked_user'.
There might be benefits in making this code generic. If there are other cases in future that need to extend error responses via codes and details, then generic code will require no new code changes in Auth0.js.
Do you think it makes sense to check if error_codes and error_details are present, then just include them in the response object in generic manner ( and not wrap it in blockedUser object)?

{
code: 'blocked_user',
description: 'Blocked user.',
codes: [ 'reason-1', 'reason-2' ],
details: {
'reason-1': {
timestamp: 123786498
},
'reason-2': {
timestamp: 127836389
}
}
}

or

{
code: 'blocked_user',
description: 'Blocked user.',
errorDetails: {
codes: [ 'reason-1', 'reason-2' ],
details: {
'reason-1': {
timestamp: 123786498
},
'reason-2': {
timestamp: 127836389
}
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madsharm I like the second option here, primarily because the first one has both code and codes at the same level on the object, which could be confusing.

Agreed with making it more generic though. Let me make some changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@madsharm I made those changes in fcc484c

Let me know what you think

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and thanks for doing the change

Steve Hobbs and others added 2 commits March 23, 2020 15:21
* Removed check for `blocked_users` code
* Changed property name on error object from `blockUser` to
`errorDetails`
@stevehobbsdev stevehobbsdev merged commit a7e55bf into master Mar 27, 2020
@stevehobbsdev stevehobbsdev deleted the feature/blocked-reasons branch March 27, 2020 12:34
@stevehobbsdev stevehobbsdev changed the title [SDK-1405] Added support for new 'blocked_reasons' error type [SDK-1405] Added support for new generic error details Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants