IBM / newrelic-cli

New Relic CLI is a command line tool which is used to operate New Relic objects(Synthetic monitors, alert policies, conditions, account users etc). You can use it easily to list/get/create/delete these objects. It can be used to backup your New Relic configuration data and restore in the future. It is easy to be used other than calling different REST API endpoints.
Apache License 2.0
62 stars 30 forks source link

`nr get users` fails with `call of reflect.Value.Interface on zero Value` #7

Closed stephenchu closed 5 years ago

stephenchu commented 5 years ago

Using:

$ nr version
v0.1.5

Got this when I run:

$ nr get users
panic: reflect: call of reflect.Value.Interface on zero Value

goroutine 1 [running]:
reflect.valueInterface(0x0, 0x0, 0x0, 0x1, 0xc42030a2a0, 0xc4204fc000)
        /Users/gaochan/Documents/zwork/software/Golang/go/src/reflect/value.go:936 +0x1bf
reflect.Value.Interface(0x0, 0x0, 0x0, 0x1, 0x2)
        /Users/gaochan/Documents/zwork/software/Golang/go/src/reflect/value.go:931 +0x44
github.com/IBM/newrelic-cli/utils.(*TablePrinter).Print(0xba9fc8, 0x840ee0, 0xc4200dca20, 0xb43880, 0xc42000c018)
        /Users/gaochan/Documents/zwork/workspace-go/src/github.com/IBM/newrelic-cli/utils/printer.go:130 +0x2f3
github.com/IBM/newrelic-cli/cmd/get.glob..func16(0xb80fa0, 0xba9fc8, 0x0, 0x0)
        /Users/gaochan/Documents/zwork/workspace-go/src/github.com/IBM/newrelic-cli/cmd/get/get_users.go:69 +0x384
github.com/IBM/newrelic-cli/vendor/github.com/spf13/cobra.(*Command).execute(0xb80fa0, 0xba9fc8, 0x0, 0x0, 0xb80fa0, 0xba9fc8)
        /Users/gaochan/Documents/zwork/workspace-go/src/github.com/IBM/newrelic-cli/vendor/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/IBM/newrelic-cli/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xb7cac0, 0xb7cd20, 0xb81920, 0xb7cf80)
        /Users/gaochan/Documents/zwork/workspace-go/src/github.com/IBM/newrelic-cli/vendor/github.com/spf13/cobra/command.go:852 +0x334
github.com/IBM/newrelic-cli/vendor/github.com/spf13/cobra.(*Command).Execute(0xb7cac0, 0x0, 0xc42012bf48)
        /Users/gaochan/Documents/zwork/workspace-go/src/github.com/IBM/newrelic-cli/vendor/github.com/spf13/cobra/command.go:800 +0x2b
github.com/IBM/newrelic-cli/cmd.Execute()
        /Users/gaochan/Documents/zwork/workspace-go/src/github.com/IBM/newrelic-cli/cmd/root.go:56 +0x31
main.main()
        /Users/gaochan/Documents/zwork/workspace-go/src/github.com/IBM/newrelic-cli/nr.go:20 +0x20
gaochan-1 commented 5 years ago

Hi @stephenchu

Thanks for your request. It seems that the problem caused by the output printed. The default output format is as TABLE. My testing data is OK in output TABLE format, maybe your data is more complex than mine.

Can you please try to append -o json argument to output as JSON format to narrow down the problem scope if it caused by printer? Like: nr get users -o json

Thanks! Chan Gao

stephenchu commented 5 years ago

Interesting: You're right. I was able to do both nr get users -o {json,yaml} just fine.

stephenchu commented 5 years ago

I do see from the stack trace that it is trying to reference a path of /Users/gaochan/Documents/zwork/software/Golang, which I obviously don't have. Could that be the issue?

gaochan-1 commented 5 years ago

@stephenchu

Thanks for your testing so much. I will do further debugging for this.

Thanks! Chan Gao