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

Deciphering validation-error, expectedType matches value #427

Open
HemalR opened this issue Feb 22, 2021 · 4 comments
Open

Deciphering validation-error, expectedType matches value #427

HemalR opened this issue Feb 22, 2021 · 4 comments

Comments

@HemalR
Copy link

HemalR commented Feb 22, 2021

I get this sporadic error for one of my methods:

{
	description: 'Part number must be of type Number',
	errorType: 'ClientError',
	name: 'ClientError',
	error: 'validation-error',
	details: [
		{
			name: 'partNumber',
			value: 1,
			type: 'expectedType',
			dataType: 'Number',
			message: 'Part number must be of type Number',
		},
	],
};

The value in question 1 is of the type defined in the schema: Number. Am I misreading something in the error? Would it make sense to modify the message to say: X must be of type Number but received {actual received type}?

The fact that it is sporadic (for a method that is fired a few thousand times a day I get this error 1-2 times) is making it difficult to debug. Any tips/suggestions/obvious oversights in the error message above much appreciated.

Thanks

@github-actions
Copy link

Thank you for submitting an issue!

If this is a bug report, please be sure to include, at minimum, example code showing a small schema and any necessary calls with all their arguments, which will reproduce the issue. Even better, you can link to a saved online code editor example, where anyone can immediately run the code and see the issue.

If you are requesting a feature, include a code example of how you imagine it working if it were implemented.

If you need to edit your issue description, click the [...] and choose Edit.

Be patient. This is a free and freely licensed package that I maintain in my spare time. You may get a response in a day, but it could also take a month. If you benefit from this package and would like to see more of my time devoted to it, you can help by sponsoring.

@aldeed
Copy link
Collaborator

aldeed commented Apr 8, 2021

I agree generally that it could be helpful to state what incorrect type was found. In JavaScript it isn't always quite so simple to just get a string name for the type. I think this could be done, but exactly how the actual type is determined would need to be implemented carefully based on exactly how and why the type check failed.

Regarding the actual error, the check that causes this is if (typeof keyValue !== 'number' || isNaN(keyValue)). So my only thought is that there is some browser error or some package overriding the implementation of the isNaN global, causing a false failure.

@HemalR
Copy link
Author

HemalR commented Apr 24, 2021

Thanks for the suggested possible line of investigation to get to the bottom of this @aldeed

Just thinking along the lines of the isNan implementation being overridden - wouldn't that lead to subsequent method calls (a couple of seconds later, by the same client on the same browser during the same session) also failing? That hasn't been the case though with a reattempt working okay and the error not being replicable.

@aldeed
Copy link
Collaborator

aldeed commented May 5, 2021

Agree it's unlikely but unless you can reliably reproduce the issue it will be difficult to figure out what is really happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants