-
Notifications
You must be signed in to change notification settings - Fork 14
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
nil pointer panic validating simple enum schema against invalid value #16
Comments
This looks like a bug, but I can't be sure - I need to run this in my test-rig to see what the problem is. Thanks for finding this! |
OK, so after looking at this, the issue lies with the assumption I made that all schemas put into the validator, will contain a So the solution here is to not assume that the schema is even a schema. Because the |
I will create a fix and publish a new version shortly. |
As reported in #16, types may not always exist (so the schema is completely invalid anyway). However, it’s important to make sure that we check for the type, before using it. Signed-off-by: Dave Shanley <dave@quobix.com>
As reported in #16, types may not always exist (so the schema is completely invalid anyway). However, it’s important to make sure that we check for the type, before using it. Signed-off-by: Dave Shanley <dave@quobix.com>
fixed in |
thanks for the fix and explanation, Dave. I now see that adding |
I am trying to use the schema_validation module to validate against a schema containing a single string enum property. Validation succeeds when one of the enum values is provided, but instead of giving an error when validation fails there's a nil pointer panic.
Here's a full example:
and the output:
It appears that
schema.GoLow().Type.KeyNode
is nil and the code trying to add the error attempts to use it without a nil check. Is it expected that KeyNode should ever be nil?The text was updated successfully, but these errors were encountered: