Panics on checkPassword with alias

Following query:

verify: checkUserPassword(email:"user@domain.com",passwd:"mysecret") {
    email
  }

works OK with dgraph/dgraph:v20.11.0-rc1-9-ge5785d9e0, but panics with dgraph/dgraph:v20.11.0-rc2-5-g2188e742c or dgraph/dgraph:master with:

panic: runtime error: index out of range [0] with length 0.
 trace: goroutine 1274 [running]:
runtime/debug.Stack(0xc0027e9870, 0x1c6d560, 0xc00109c140)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9d
github.com/dgraph-io/dgraph/graphql/api.PanicHandler(0xc0027e9f28)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/api/panics.go:33 +0x57
panic(0x1c6d560, 0xc00109c140)
	/usr/local/go/src/runtime/panic.go:969 +0x166
github.com/dgraph-io/dgraph/graphql/resolve.passwordQuery(0x1ff1180, 0xc001c18d20, 0xc001fa8be0, 0x7fcd79e8e438, 0xc001c18d20, 0xc0018c6180)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/query_rewriter.go:213 +0x99a
github.com/dgraph-io/dgraph/graphql/resolve.(*queryRewriter).Rewrite(0x30366e8, 0x1fccf00, 0xc001c18510, 0x1ff1180, 0xc001c18d20, 0x0, 0xc001c18db0, 0x8)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/query_rewriter.go:157 +0x5e1
github.com/dgraph-io/dgraph/graphql/resolve.(*queryResolver).rewriteAndExecute(0xc001c18d50, 0x1fccf00, 0xc001c18510, 0x1ff1180, 0xc001c18d20, 0xc001c18d50)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/query.go:137 +0x22c
github.com/dgraph-io/dgraph/graphql/resolve.(*queryResolver).Resolve(0xc001c18d50, 0x1fccf00, 0xc001c18510, 0x1ff1180, 0xc001c18d20, 0x0)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/query.go:86 +0x32d
github.com/dgraph-io/dgraph/graphql/resolve.(*RequestResolver).Resolve.func2.1(0xc0018c6164, 0xc0006ca080, 0x1, 0x1, 0xc0025f8400, 0x1fccf00, 0xc001c18510, 0x1ff1180, 0xc001c18d20, 0x0)
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/resolver.go:467 +0x165
created by github.com/dgraph-io/dgraph/graphql/resolve.(*RequestResolver).Resolve.func2
	/ext-go/1/src/github.com/dgraph-io/dgraph/graphql/resolve/resolver.go:457 +0x1e0

Thanks for reporting the bug. I am trying to reproduce this.
Can you share schema or the fields of type User ?

Sure. Schema:

type User @secret(field:"passwd") {
  email: String! @id @search(by: [hash])
  first_name: String @search(by: [hash])
  last_name: String @search(by: [hash])
}

Mutation:

mutation {
  addUser(input:[
    {first_name:"John",last_name:"Doe",email:"user@domain.com",passwd:"secret"}
  ]) {numUids}
}

Thanks, I was able to reproduce this. I have marked the status as accepted. A fix will be merged to master branch soon.

The fix for this issue has been merged to master over here: Fix(GraphQL): Fix bug with password query rewriting by vmrajas · Pull Request #7011 · dgraph-io/dgraph · GitHub . Let us know if you face any other issues.
Once again, Thanks for trying out the feature and reporting the bug.

Thanks, everything works as expected for master. Looking forward to a new tagged rc2 docker image.