fnproject / cli

CLI tool for fnproject.
https://fnproject.io
Apache License 2.0
132 stars 66 forks source link

"fn app list" crashes when FN_API_URL is pointing to a kubectl proxy URL #159

Open kojustin opened 6 years ago

kojustin commented 6 years ago

I'm running the project inside of a minikube distribution using fn-helm. The FN_API_URL is pointing at kubectl proxy which is proxying access into the Kubernetes cluster.

$ curl http://127.0.0.1:8001/api/v1/namespaces/default/services/jko-fn-api:80/proxy/
{"goto":"https://github.com/fnproject/fn","hello":"world!"}%                                                      
$ export FN_API_URL=http://127.0.0.1:8001/api/v1/namespaces/default/services/jko-fn-api:80/proxy/

When I do "fn apps list" I get a crash.

$ /gospace/bin/fn apps list
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x152a3f7]

goroutine 1 [running]:
main.(*appsCmd).list(0xc42000e0c0, 0xc4200c69a0, 0x0, 0x0)
    /gospace/src/github.com/fnproject/cli/apps.go:140 +0x717
main.(*appsCmd).(main.list)-fm(0xc4200c69a0, 0x0, 0x0)
    /gospace/src/github.com/fnproject/cli/apps.go:102 +0x34
github.com/fnproject/cli/vendor/github.com/urfave/cli.HandleAction(0x15c4b60, 0xc42019ece0, 0xc4200c69a0, 0x0, 0x0)
    /gospace/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:490 +0xd2
main.prepareCmdArgsValidation.func1(0xc4200c69a0, 0x0, 0xc4200c69a0)
    /gospace/src/github.com/fnproject/cli/main.go:125 +0x26d
github.com/fnproject/cli/vendor/github.com/urfave/cli.HandleAction(0x15c4b60, 0xc420505b40, 0xc4200c69a0, 0xc420060d00, 0x0)
    /gospace/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:490 +0xd2
github.com/fnproject/cli/vendor/github.com/urfave/cli.Command.Run(0x168fc40, 0x4, 0x0, 0x0, 0xc42019eda0, 0x1, 0x1, 0x1698ef4, 0xd, 0x0, ...)
    /gospace/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/command.go:210 +0xa95
github.com/fnproject/cli/vendor/github.com/urfave/cli.(*App).RunAsSubcommand(0xc420343ba0, 0xc4200c6580, 0x0, 0x0)
    /gospace/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:379 +0xa7b
github.com/fnproject/cli/vendor/github.com/urfave/cli.Command.startApp(0x168f7d4, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x169e1c1, 0x13, 0x0, ...)
    /gospace/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/command.go:298 +0x944
github.com/fnproject/cli/vendor/github.com/urfave/cli.Command.Run(0x168f7d4, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x169e1c1, 0x13, 0x0, ...)
    /gospace/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/command.go:98 +0x1319
github.com/fnproject/cli/vendor/github.com/urfave/cli.(*App).Run(0xc420343a00, 0xc4200101b0, 0x3, 0x3, 0x0, 0x0)
    /gospace/src/github.com/fnproject/cli/vendor/github.com/urfave/cli/app.go:255 +0x6f8
main.main()
    /gospace/src/github.com/fnproject/cli/main.go:133 +0x4f

I built this version of the fn cli tool at

commit 12693401153dc461f2629251103ffaa0f55b421f
Author: CI <ci@fnproject.com>
Date:   Fri Feb 2 00:51:18 2018 +0000

    fn CLI: 0.4.45 release [skip ci]
rdallman commented 6 years ago

this panic is from bad error handling of nested e.Payload.Error.Message, one of which is nil, related to #32 our error handling of the swagger errors is pretty buggy, there are multiple locations we need to do better extraction of e.Payload.Error.Message. thanks for filing. fixing shouldn't be too bad for this specific case, but at least you're getting an error which you could print out to at least get you past this.

smells like more of a dance with k8s proxy than anything