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

crypto: fix wrong error message #33482

Closed
wants to merge 5 commits into from
Closed

crypto: fix wrong error message #33482

wants to merge 5 commits into from

Conversation

benbucksch
Copy link
Contributor

@benbucksch benbucksch commented May 20, 2020

When calling crypto.sign(), if the key parameter object is
missing the key property, the error message is wrong.

Before the fix:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of
type string or an instance of Buffer, TypedArray, DataView, or
KeyObject. Received an instance of Object

Expected:
TypeError [ERR_INVALID_ARG_TYPE]: The "key.key" property
must be of type string or an instance of Buffer, TypedArray,
DataView, or KeyObject. Received undefined

Fixes: #33480
This seems like a copy&paste bug. Somebody copied from the end of
the function, where this is correct, to here, where it's wrong.

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

When calling `crypto.sign()`, if the `key` parameter object is
missing the `key` property, the error message is wrong.

Before the fix:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of
type string or an instance of Buffer, TypedArray, DataView, or
KeyObject. Received an instance of Object

Expected:
TypeError [ERR_INVALID_ARG_TYPE]: The "key.key property" argument
must be of type string or an instance of Buffer, TypedArray,
DataView, or KeyObject. Received undefined

Fixes: #33480
This seems like a copy&paste bug. Somebody copied from the end of
the function, where this is correct, to here, where it's wrong.
@nodejs-github-bot nodejs-github-bot added the crypto Issues and PRs related to the crypto subsystem. label May 20, 2020
@benbucksch
Copy link
Contributor Author

benbucksch commented May 20, 2020

(removed comment regarding failed test)

Copy link
Member

@himself65 himself65 left a comment

Choose a reason for hiding this comment

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

and unit tests need an update too

@benbucksch
Copy link
Contributor Author

and unit tests need an update too

I'm on it.

@benbucksch
Copy link
Contributor Author

Review change done. Tests fixed.

@benbucksch
Copy link
Contributor Author

benbucksch commented May 20, 2020

Ready to merge.

Seems like the tests pass.

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM. Great work and good catch!

@nodejs-github-bot
Copy link
Collaborator

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 23, 2020
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented May 23, 2020

@BridgeAR
Copy link
Member

@nodejs/crypto this could use another review.

Copy link
Contributor

@ryzokuken ryzokuken left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the ping, @BridgeAR.

BridgeAR pushed a commit to BridgeAR/node that referenced this pull request May 25, 2020
When calling `crypto.sign()`, if the `key` parameter object is
missing the `key` property, the error message is wrong.

Before the fix:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of
type string or an instance of Buffer, TypedArray, DataView, or
KeyObject. Received an instance of Object

Expected:
TypeError [ERR_INVALID_ARG_TYPE]: The "key.key property" argument
must be of type string or an instance of Buffer, TypedArray,
DataView, or KeyObject. Received undefined

This seems like a copy&paste bug. Somebody copied from the end of
the function, where this is correct, to here, where it's wrong.

PR-URL: nodejs#33482
Fixes: nodejs#33480
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
@BridgeAR
Copy link
Member

Landed in 2f00ca4

@BridgeAR BridgeAR closed this May 25, 2020
@benbucksch
Copy link
Contributor Author

Thanks! :)

@benbucksch benbucksch deleted the crypto-error branch May 26, 2020 00:34
codebytere pushed a commit that referenced this pull request Jun 18, 2020
When calling `crypto.sign()`, if the `key` parameter object is
missing the `key` property, the error message is wrong.

Before the fix:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of
type string or an instance of Buffer, TypedArray, DataView, or
KeyObject. Received an instance of Object

Expected:
TypeError [ERR_INVALID_ARG_TYPE]: The "key.key property" argument
must be of type string or an instance of Buffer, TypedArray,
DataView, or KeyObject. Received undefined

This seems like a copy&paste bug. Somebody copied from the end of
the function, where this is correct, to here, where it's wrong.

PR-URL: #33482
Fixes: #33480
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
@codebytere codebytere mentioned this pull request Jun 28, 2020
codebytere pushed a commit that referenced this pull request Jun 30, 2020
When calling `crypto.sign()`, if the `key` parameter object is
missing the `key` property, the error message is wrong.

Before the fix:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of
type string or an instance of Buffer, TypedArray, DataView, or
KeyObject. Received an instance of Object

Expected:
TypeError [ERR_INVALID_ARG_TYPE]: The "key.key property" argument
must be of type string or an instance of Buffer, TypedArray,
DataView, or KeyObject. Received undefined

This seems like a copy&paste bug. Somebody copied from the end of
the function, where this is correct, to here, where it's wrong.

PR-URL: #33482
Fixes: #33480
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
codebytere pushed a commit that referenced this pull request Jul 8, 2020
When calling `crypto.sign()`, if the `key` parameter object is
missing the `key` property, the error message is wrong.

Before the fix:
TypeError [ERR_INVALID_ARG_TYPE]: The "key" argument must be of
type string or an instance of Buffer, TypedArray, DataView, or
KeyObject. Received an instance of Object

Expected:
TypeError [ERR_INVALID_ARG_TYPE]: The "key.key property" argument
must be of type string or an instance of Buffer, TypedArray,
DataView, or KeyObject. Received undefined

This seems like a copy&paste bug. Somebody copied from the end of
the function, where this is correct, to here, where it's wrong.

PR-URL: #33482
Fixes: #33480
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
@codebytere codebytere mentioned this pull request Jul 13, 2020
@EEZHI
Copy link

EEZHI commented Oct 15, 2020

I get this error when i run 'knex migrate:latest" and I have no idea how to fix it. Been on it for days

@benbucksch
Copy link
Contributor Author

benbucksch commented Oct 15, 2020

@EEZHI : If you get this error message, you (or whoever wrote the code you run) are using the API wrong, specifically the type of one of your parameters is wrong. The API here is very confusing, because it accepts several different types for backward compat, so please read the docs very very carefully and slowly. I had severe trouble to understand it as well.

If you still can't figure it out, post somewhere on a developer help forum. This ticket here is not the right place for getting help about your problem.

@EEZHI
Copy link

EEZHI commented Oct 16, 2020

@EEZHI : If you get this error message, you (or whoever wrote the code you run) are using the API wrong, specifically the type of one of your parameters is wrong. The API here is very confusing, because it accepts several different types for backward compat, so please read the docs very very carefully and slowly. I had severe trouble to understand it as well.

If you still can't figure it out, post somewhere on a developer help forum. This ticket here is not the right place for getting help about your problem.

Alright thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong and misleading error message from crypto.sign(..., key)
6 participants