Skip to content

Commit

Permalink
Fix bug for queries with @recurse and expand(_all_). (#3179)
Browse files Browse the repository at this point in the history
Currently this type of queries might result in an unrecoverable error
in the alpha. This happens for example, while trying to expand on a node
of type PASSWORD.

The reason is that handleValuePostings and handleUidPostings sometimes
successfully return early without setting the UidMatrix field.

This change adds a fix and modifies the existing test to trigger this
case. I have verified that the test crashes the alpha when the fix is
absent.
  • Loading branch information
martinmr authored Mar 20, 2019
1 parent 859edf0 commit 3081fc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions query/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ func populateCluster() {
<36> <abbr> "CA" .
<1> <password> "123456" .
<32> <password> "123456" .
<23> <pass> "654321" .
<23> <shadow_deep> "4" .
Expand Down
5 changes: 5 additions & 0 deletions query/recurse.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ func (start *SubGraph) expandRecurse(ctx context.Context, maxDepth uint64) error
}

for _, sg := range exec {
// sg.uidMatrix can be empty. Continue if that is the case.
if len(sg.uidMatrix) == 0 {
continue
}

if sg.UnknownAttr {
continue
}
Expand Down

0 comments on commit 3081fc1

Please sign in to comment.