-
Notifications
You must be signed in to change notification settings - Fork 358
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
add check for schema map[string]interface{} asssertion #269
add check for schema map[string]interface{} asssertion #269
Conversation
b295f20
to
a04a820
Compare
a04a820
to
9fced13
Compare
After testing this library with errcheck with
So I am going to fix. |
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 is definitely an overlooked oopsie, so thanks for the PR. I have one minor nitpick, but that is about it. 👍
draft.go
Outdated
@@ -92,7 +92,10 @@ func parseSchemaURL(documentNode interface{}) (string, *Draft, error) { | |||
if isKind(documentNode, reflect.Bool) { | |||
return "", nil, nil | |||
} | |||
m := documentNode.(map[string]interface{}) | |||
m, ok := documentNode.(map[string]interface{}) |
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.
Most of the code uses the isKind
helper method, so to keep the style similar to the rest of the code it's probably better to change this into:
if !isKind(documentNode, reflect.Map) {
return "", nil, errors.New("schema is invalid")
}
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.
Fixed : )
c0198cb
to
d5702d9
Compare
@dbadura Thank you for looking at those issues. I looked at a couple of them and I suspect most of them are false positives. From the couple I quickly looked at all of them had a type check somewhere, although not in the format errcheck expects. If you find another error that definitely needs to be checked, please let me know, but I don't want to clutter the code with redundant error handling because some linting tool said so. |
Thank you. I noticed how you do the assertion type later : ) |
When you use
GoLoader
and put something that is notmap[string]interface{}
the library panic on nil value, because indraft.go
, line 95m := documentNode.(map[string]interface{})
, assertion is not checked.our issue