Merged
Conversation
Empty variables have nil value and default type, this change adds sanity checks before the value is type asserted and cause panic.
codexnull
approved these changes
Feb 15, 2019
Contributor
codexnull
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r1.
Reviewable status:complete! all files reviewed, all discussions resolved
added 4 commits
February 14, 2019 18:57
Val types use a field Value which is an interface. Type assertions of Value will panic when it is nil. The Safe() function will ensure a non-nil Value is returned. It won't change it, only make type assertions safer. Note that invalid type assertions are still possible.
A Val of type DefaultID could be a default value, play it safe.
martinmr
approved these changes
Feb 15, 2019
Contributor
martinmr
left a comment
There was a problem hiding this comment.
Reviewed 4 of 4 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved
dna2github
pushed a commit
to dna2fork/dgraph
that referenced
this pull request
Jul 19, 2019
* types/sort.go: sanity check for empty variables Empty variables have nil value and default type, this change adds sanity checks before the value is type asserted and cause panic. * query/query.go: enhanced default value vars comment * types/scalar_types.go: added func Safe() Val types use a field Value which is an interface. Type assertions of Value will panic when it is nil. The Safe() function will ensure a non-nil Value is returned. It won't change it, only make type assertions safer. Note that invalid type assertions are still possible. * types/conversion.go: use Safe() in MarshalJSON() for DefaultID A Val of type DefaultID could be a default value, play it safe. * types/sort.go: use Safe() and narrow the field to DefaultID * types/sort.go: revert unneeded change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Empty variables have nil value and default type, this change
adds sanity checks before the value is type asserted and cause panic.
This change is