GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — crypto: extract throwInvalidArgType function by danbev · Pull Request #22947 · nodejs/node

Conversation

@danbev

@danbev danbev commented Sep 19, 2018

Copy link
Copy Markdown
Contributor

This commit extracts the throwing of ERR_INVALID_ARG_TYPE which is done
in identical ways in a few places in cipher.js.

The motivation for this is that I think it improves readability enough to
warrant a commit even though I'm aware that we should avoid commits with
only these sort of refactoring.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot

nodejs-github-bot commented Sep 19, 2018

Copy link
Copy Markdown
Collaborator

@danbev build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/941/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the crypto Issues and PRs related to the crypto subsystem. label Sep 19, 2018
@danbev

danbev commented Sep 19, 2018

Copy link
Copy Markdown
Contributor Author

CI: https://ci.nodejs.org/job/node-test-pull-request/17321/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tniessen

tniessen commented Sep 19, 2018

Copy link
Copy Markdown
Member

Not opposed to this change, but the name throwInvalidArgType is too generic IMO. It is only used for certain types and the function name should reflect that, even though I currently don't have a better idea.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danbev

danbev commented Sep 20, 2018

Copy link
Copy Markdown
Contributor Author

Not opposed to this change, but the name throwInvalidArgType is too generic IMO

Yeah, I agree. I was struggling to come up with a good name. Let me try to come up with a better name for the function.

danbev reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax approved these changes Sep 22, 2018
View reviewed changes
@addaleax

addaleax commented Sep 22, 2018

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-pull-request/17372/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 22, 2018
BridgeAR
BridgeAR reviewed Sep 23, 2018
View reviewed changes
Comment thread lib/internal/crypto/cipher.js Outdated

@BridgeAR BridgeAR Sep 23, 2018

Copy link
Copy Markdown
Member

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.

This change seems like a mistake. The toBuf() function accepts a string and transform that into a buffer.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@danbev danbev Sep 24, 2018

Copy link
Copy Markdown
Contributor Author

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.

The motivation for this changes was that toBuf() would convert any string passed in to a Buffer, and therefore isArrayBufferView would not be passed a string for the password, key, and iv cases.

Note that my first commit also updated the update function which does not call toBuf() which was a mistake and this as fixed in the latest commit, so update will also include the string in its throws cause.

Does that still sound incorrect?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@BridgeAR BridgeAR Sep 24, 2018

Copy link
Copy Markdown
Member

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.

The error message corresponds to the possible values for the user, not to possible transformations we do internally before throwing the error. So string should still be valid in all of these cases.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@danbev danbev Sep 25, 2018

Copy link
Copy Markdown
Contributor Author

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.

Sorry about the late reply. I see your point now, I'll revert my latest change. Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@BridgeAR BridgeAR removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 23, 2018
thefourtheye
thefourtheye approved these changes Sep 25, 2018
View reviewed changes
Comment thread lib/internal/crypto/cipher.js Outdated

@thefourtheye thefourtheye Sep 25, 2018

Copy link
Copy Markdown
Contributor

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.

Nit: I would prefer constructing the error object in the function and throwing it explicitly here. I think it would be better during the reviews and one less line in the stack trace 😉.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@danbev danbev Sep 25, 2018

Copy link
Copy Markdown
Contributor Author

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.

That makes sense. I'll update shortly. Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@danbev

danbev commented Sep 25, 2018

Copy link
Copy Markdown
Contributor Author

New CI: https://ci.nodejs.org/job/node-test-pull-request/17419/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

thefourtheye
thefourtheye approved these changes Sep 25, 2018
View reviewed changes
@danbev

danbev commented Sep 25, 2018

Copy link
Copy Markdown
Contributor Author

Re-run of failing node-test-commit-smartos and node-test-commit-linux.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Sep 25, 2018
View reviewed changes
@joyeecheung joyeecheung mentioned this pull request Sep 25, 2018
CI failures: 20180925 nodejs/reliability#17
Closed
@danbev
crypto: extract throwInvalidArgType function
310ed4f
This commit extracts the throwing of ERR_INVALID_ARG_TYPE which is done
in identical ways in a few places in cipher.js.

The motivation for this is that I think it improves readability enough to
warrant a commit even though I'm aware that we should avoid commits with
only these sort of refactoring.
@danbev
danbev force-pushed the cipher_throwInvalidArgType branch from 0c53f0e to 310ed4f Compare September 27, 2018 03:09
@danbev

danbev commented Sep 27, 2018

Copy link
Copy Markdown
Contributor Author

Rebased CI: https://ci.nodejs.org/job/node-test-pull-request/17461/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tniessen
tniessen approved these changes Sep 27, 2018
View reviewed changes
BridgeAR
BridgeAR approved these changes Sep 27, 2018
View reviewed changes
@BridgeAR BridgeAR added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Sep 27, 2018
@danbev

danbev commented Oct 2, 2018

Copy link
Copy Markdown
Contributor Author

New CI: https://ci.nodejs.org/job/node-test-pull-request/17579/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joyeecheung joyeecheung mentioned this pull request Oct 2, 2018
CI failures: 20180927-20181002 nodejs/reliability#18
Closed
@danbev

danbev commented Oct 2, 2018

Copy link
Copy Markdown
Contributor Author

Re-run of failing node-test-commit-arm

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danbev

danbev commented Oct 3, 2018

Copy link
Copy Markdown
Contributor Author

Landed in b25e6ab.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danbev danbev closed this Oct 3, 2018
@danbev
danbev deleted the cipher_throwInvalidArgType branch October 3, 2018 06:14
danbev added a commit that referenced this pull request Oct 3, 2018
@danbev
crypto: extract throwInvalidArgType function
b25e6ab
This commit extracts the throwing of ERR_INVALID_ARG_TYPE which is done
in identical ways in a few places in cipher.js.

The motivation for this is that I think it improves readability enough to
warrant a commit even though I'm aware that we should avoid commits with
only these sort of refactoring.

PR-URL: #22947
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
targos pushed a commit that referenced this pull request Oct 4, 2018
@danbev @targos
crypto: extract throwInvalidArgType function
f98d441
This commit extracts the throwing of ERR_INVALID_ARG_TYPE which is done
in identical ways in a few places in cipher.js.

The motivation for this is that I think it improves readability enough to
warrant a commit even though I'm aware that we should avoid commits with
only these sort of refactoring.

PR-URL: #22947
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
@targos targos mentioned this pull request Oct 7, 2018
Release proposal: v10.12.0 #23313
Merged
This was referenced Oct 10, 2018
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#225
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#239
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#226
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#240
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#227
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#241
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#242
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#228
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-android-nodejs#243
Closed
2018-10-10 Version 10.12.0 (Current) @targos beevelop/docker-nodejs#229
Closed
jasnell pushed a commit that referenced this pull request Oct 17, 2018
@danbev @jasnell
crypto: extract throwInvalidArgType function
c90663b
This commit extracts the throwing of ERR_INVALID_ARG_TYPE which is done
in identical ways in a few places in cipher.js.

The motivation for this is that I think it improves readability enough to
warrant a commit even though I'm aware that we should avoid commits with
only these sort of refactoring.

PR-URL: #22947
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes
@tniessen tniessen tniessen approved these changes
@BridgeAR BridgeAR BridgeAR approved these changes
+1 more reviewer
@thefourtheye thefourtheye thefourtheye approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. crypto Issues and PRs related to the crypto subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@danbev @nodejs-github-bot @tniessen @addaleax @jasnell @thefourtheye @BridgeAR
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.