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 1518137 - better libraries/api error handling, fix InsufficientScopes #54

Merged
merged 1 commit into from
Jan 7, 2019

Conversation

djmitche
Copy link
Collaborator

@djmitche djmitche commented Jan 7, 2019

The important thing here is not losing track of the message template, so
users still see the explanation of their InsufficientScopes error. But
this also factors out the translation of AuthorizationError ->
InsufficientScopes and AuthenticationError -> AuthenticationFailed.

…opes

The important thing here is not losing track of the message template, so
users still see the explanation of their InsufficientScopes error.  But
this also factors out the translation of AuthorizationError ->
InsufficientScopes and AuthenticationError -> AuthenticationFailed.
@djmitche djmitche self-assigned this Jan 7, 2019
throw new ErrorReply({
code: 'AuthenticationFailed',
message: result.message,
details: result,
Copy link
Collaborator

Choose a reason for hiding this comment

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

So that result object - does it have the information about which scopes are missing anywhere in it? Should we be showing that information at all in the authorization case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This error is for bad Hawk credentials, not bad scopes - so no, not in this case.

@@ -319,11 +317,6 @@ const remoteAuthentication = ({signatureValidator, entry}) => {
next();
}
} catch (err) {
if (err.code === 'AuthorizationError') {
return next(new ErrorReply({code: 'InsufficientScopes', message: err.messageTemplate, details: err.details}));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm quite puzzled. The error that Simon reported lacked details field completely (or at least it wasn't showing up in the logs). Why would that be?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The original bug was, indeed, right here -- we passed err.messageTemplate (which is undefined) instead of err.message (which contains the message simon expected). The minimal fix to that bug was just messageTemplate -> message, but I took the chance to clean up some messiness in handling errors while I was at it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, hold on. The code says: if (err.code === 'AuthorizationError') - the code of the offending error was InsufficientScopes (although the message was, indeed, Authorization failed). And the template was absent from the err.message, and details field was missing from the error object altogether

Copy link
Collaborator

@owlishDeveloper owlishDeveloper Jan 7, 2019

Choose a reason for hiding this comment

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

Ok, I am quite confused by this piece of code (as I was confused by the error object) - it's good it's gone in your PR 😆

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it was a bit of leftovers from the refactor that @arshadkazmi42 worked on.

Copy link
Collaborator

@owlishDeveloper owlishDeveloper left a comment

Choose a reason for hiding this comment

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

The new changes make more sense to me!

@@ -253,12 +253,11 @@ const remoteAuthentication = ({signatureValidator, entry}) => {
// If authentication failed
if (result.status === 'auth-failed') {
res.set('www-authenticate', 'hawk');
const err = new Error('Authentication failed'); // This way instead of subclassing due to babel/babel#3083
Copy link
Contributor

Choose a reason for hiding this comment

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

Bye bye babel.

@djmitche djmitche merged commit 6e9cc0b into taskcluster:master Jan 7, 2019
@djmitche
Copy link
Collaborator Author

djmitche commented Jan 7, 2019

deploying now

owlishDeveloper pushed a commit to owlishDeveloper/taskcluster that referenced this pull request Jan 10, 2019
owlishDeveloper pushed a commit to owlishDeveloper/taskcluster that referenced this pull request Jan 16, 2019
owlishDeveloper pushed a commit to owlishDeveloper/taskcluster that referenced this pull request Jan 16, 2019
petemoore pushed a commit that referenced this pull request Feb 18, 2020
…ter-taskcluster-clients-client-go-v21-21.x

Update module taskcluster/taskcluster/clients/client-go/v21 to v21.2.0
imbstack pushed a commit that referenced this pull request May 5, 2020
Prevent zombie nodes being created from filesystem creation error
imbstack pushed a commit that referenced this pull request May 7, 2020
Prevent zombie nodes being created from filesystem creation error
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

Successfully merging this pull request may close these issues.

None yet

3 participants