Keto expand CLI API panic when the tree is empty.
counter2015 opened this issue · comments
Describe the bug
keto expand
will raise panic when the result set is empty.
Reproducing the bug
$ keto expand grant role super-admin
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x4ba8c37]
goroutine 1 [running]:
github.com/ory/keto/internal/expand.(*Tree).String(0x0, 0x511ffa0, 0xc000010018)
/home/ory/internal/expand/tree.go:165 +0x37
github.com/ory/x/cmdx.PrintJSONAble(0xc0004b6500, 0x511dea0, 0x0)
/go/pkg/mod/github.com/ory/x@v0.0.228/cmdx/printing.go:131 +0x1dc
github.com/ory/keto/cmd/expand.NewExpandCmd.func1(0xc0004b6500, 0xc0003198f0, 0x3, 0x3, 0x0, 0x0)
/home/ory/cmd/expand/root.go:60 +0x30b
github.com/spf13/cobra.(*Command).execute(0xc0004b6500, 0xc0003198c0, 0x3, 0x3, 0xc0004b6500, 0xc0003198c0)
/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc000421400, 0xc00003a090, 0x5139a98, 0xc000316640)
/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/spf13/cobra.(*Command).ExecuteContext(...)
/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:890
github.com/ory/keto/cmd.Execute()
/home/ory/cmd/root.go:72 +0xbc
main.main()
/home/ory/main.go:26 +0x52
Expected behavior
It should return a empty set like REST API return
Lines 164 to 166 in d766968
Environment
- Version: v0.6.0-alpha.3
- Environment: Bash, Docker compose
Thanks for reporting this. It should already be fixed with #686, but it is not yet released. The next release is https://github.com/ory/keto/milestone/5 which we are working hard to get done.