-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
tls: migrate tls.js to use internal/errors.js #13994
Conversation
lib/internal/errors.js
Outdated
@@ -111,6 +111,8 @@ module.exports = exports = { | |||
// Note: Please try to keep these in alphabetical order | |||
E('ERR_ARG_NOT_ITERABLE', '%s must be iterable'); | |||
E('ERR_ASSERTION', '%s'); | |||
E('ERR_CERT_ALTNAME_INVALID', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERR_TLS_CERT_ALTNAME_INVALID
?
lib/internal/errors.js
Outdated
@@ -111,6 +111,8 @@ module.exports = exports = { | |||
// Note: Please try to keep these in alphabetical order | |||
E('ERR_ARG_NOT_ITERABLE', '%s must be iterable'); | |||
E('ERR_ASSERTION', '%s'); | |||
E('ERR_CERT_ALTNAME_INVALID', | |||
'Hostname/IP does not match certificate\'s altnames: %s'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use a template string form to avoid having to escape?
Pushed commit to address comments. |
lib/internal/errors.js
Outdated
E('ERR_TLS_CERT_ALTNAME_INVALID', | ||
(reason) => { | ||
return `Hostname/IP does not match certificate's altnames: ${reason}`; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not have to use a function here. Instead we can rely on util.format by replacing the function with:
'Hostname/IP does not match certificate's altnames: %s'
.
This is done in all other places and it would be nice to keep it consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion, updating now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually that is what I had originally. The suggestion to use a function was from James to avoid having to escape the '. Having said that I think I prefer avoiding the function for consistency so I'll change back.
@BridgeAR pushed commit to change back to address your comment. |
@fhinkel any chance you can review this PR ? |
Needs a rebase... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add an assertion of the structure of the Error object to parallel/test-tls-friendly-error-message.js
?
Migrate tls.js to use internal/errors.js as per nodejs#11273
@refack I'm not following, I looked at the test and I don't see the relation to this PR. I see it already validates the following:
|
Rebased and squashed. |
@fhinkel just need one more CTC reviewer on this one. |
I meant you did not add an assertion of the generated error message for the new error code you introduced |
@refack I don't think we have been requiring validating the message. I had mentioned it as a discussion point when reviewing other PRs. I do agree validation at least once makes sense, but was not sure if we should require that in every test for the code. I'd suggest this as our approach going forward
I've gone ahead and pushed a commit to do that for this PR. If we agree on the above we should put that guidance into the issue tracking and our internal docs. Once we have agreement I'll do that. The alternative to 3) is that we also require that the message be validated every time the code is used. This would be most thorough. |
@mhdawson Agreed, I made the same argument almost verbatim in some other thread! |
The only caveat with (3) is if the code explicitly modifies the message after Error construction. We should mention that as a no-no in reviewing guidelines. |
@nodejs/ctc need one more reviewer as its SemVer major. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM but I can't seem to find the documentation for the old behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@joyeecheung not sure what you mean by "can't seem to find the documentation for the old behavior" ? |
One more time for CI run as last one seems not to exist: https://ci.nodejs.org/job/node-test-pull-request/9218/ |
CI run good landing. |
Landed as 3ccfeb4 |
Migrate tls.js to use internal/errors.js as per
#11273
The internal code used to set the 'code' as the client.authorizationError, or if no code existed the 'message' as the client.authorizationError. Since with the new approach there is always a 'code' we end up setting the less descriptive code. I guess that is consistent though with what was being done for existing errors with a code anyway.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
tls