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

Fix crash when trying to use shortest path with a password predicate. #3662

Merged
merged 2 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion query/query3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ func TestTwoShortestPathMinWeight(t *testing.T) {
}

func TestShortestPath(t *testing.T) {

query := `
{
A as shortest(from:0x01, to:31) {
Expand Down Expand Up @@ -517,6 +516,25 @@ func TestShortestPathRev(t *testing.T) {
js)
}

// Regression test for https://github.com/dgraph-io/dgraph/issues/3657.
func TestShortestPathPassword(t *testing.T) {
query := `
{
A as shortest(from:0x01, to:31) {
password
friend
}

me(func: uid( A)) {
name
}
}`
js := processQueryNoErr(t, query)
require.JSONEq(t,
`{"data": {"_path_":[{"uid":"0x1", "_weight_": 1, "friend":{"uid":"0x1f"}}],
"me":[{"name":"Michonne"},{"name":"Andrea"}]}}`, js)
}

func TestFacetVarRetrieval(t *testing.T) {

query := `
Expand Down
6 changes: 6 additions & 0 deletions query/shortest.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ func (sg *SubGraph) expandOut(ctx context.Context,

// Send the destuids in res chan.
for mIdx, fromUID := range subgraph.SrcUIDs.Uids {
// This can happen when trying to go traverse a predicate of type password
// for example.
if mIdx >= len(subgraph.uidMatrix) {
continue
}

for lIdx, toUID := range subgraph.uidMatrix[mIdx].Uids {
if adjacencyMap[fromUID] == nil {
adjacencyMap[fromUID] = make(map[uint64]mapItem)
Expand Down