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 label May 20, 2020
@benbucksch
Copy link
Contributor Author

@benbucksch benbucksch commented May 20, 2020

(removed comment regarding failed test)

lib/internal/crypto/keys.js Outdated Show resolved Hide resolved
Copy link
Member

@Himself65 Himself65 left a comment

and unit tests need an update too

@benbucksch
Copy link
Contributor Author

@benbucksch benbucksch commented May 20, 2020

and unit tests need an update too

I'm on it.

@benbucksch
Copy link
Contributor Author

@benbucksch benbucksch commented May 20, 2020

Review change done. Tests fixed.

@benbucksch
Copy link
Contributor Author

@benbucksch benbucksch commented May 20, 2020

Ready to merge.

Seems like the tests pass.

Copy link
Member

@BridgeAR BridgeAR left a comment

LGTM. Great work and good catch!

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented May 23, 2020

@BridgeAR BridgeAR added the author ready label May 23, 2020
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented May 23, 2020

@BridgeAR
Copy link
Member

@BridgeAR BridgeAR commented May 23, 2020

@nodejs/crypto this could use another review.

Copy link
Member

@ryzokuken ryzokuken left a comment

LGTM. Thanks for the ping, @BridgeAR.

BridgeAR added a commit to BridgeAR/node that referenced this issue 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

@BridgeAR BridgeAR commented May 25, 2020

Landed in 2f00ca4

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

@benbucksch benbucksch commented May 26, 2020

Thanks! :)

@benbucksch benbucksch deleted the crypto-error branch May 26, 2020
codebytere added a commit that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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 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 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 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 crypto
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants