segmentio/cwlogs

panic: reflect: call of reflect.Value.Type on zero Value

stephenmathieson opened this issue · 5 comments

I was grabbing logs from a service and hit this:

panic: reflect: call of reflect.Value.Type on zero Value [recovered]
	panic: reflect: call of reflect.Value.Type on zero Value

goroutine 1 [running]:
text/template.errRecover(0xc42062f858)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:146 +0x62
panic(0x144e640, 0xc42032bfe0)
	/usr/local/Cellar/go/1.8.3/libexec/src/runtime/panic.go:489 +0x2cf
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x0)
	/usr/local/Cellar/go/1.8.3/libexec/src/reflect/value.go:1688 +0x21f
github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows.FlattenPrefixedToResult(0x0, 0x0, 0xc42032bf60, 0x17, 0xc4206e8450)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows/main.go:72 +0xee
github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows.FlattenPrefixedToResult(0x14545c0, 0xc42067cf30, 0xc4211b9630, 0xc, 0xc4206e8450)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows/main.go:81 +0x588
github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows.FlattenPrefixedToResult(0x1471960, 0xc42067ced0, 0x0, 0x0, 0xc4206e8450)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows/main.go:81 +0x588
github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows.FlattenPrefixed(0x1471960, 0xc42067ced0, 0x0, 0x0, 0x13e5d40)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows/main.go:56 +0x87
github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows.Flatten(0x1471960, 0xc42067ced0, 0x104d693)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/doublerebel/bellows/main.go:51 +0x47
github.com/segmentio/cwlogs/lib.Event.DataFlat(0x7, 0xed19e9e47, 0xf42400, 0x0, 0xc4211a8b20, 0xc, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/lib/event.go:76 +0x3a
github.com/segmentio/cwlogs/lib.(*Event).DataFlat(0xc420a17800, 0x0)
	<autogenerated>:5 +0x80
reflect.Value.call(0x14b2560, 0xc420a17800, 0x693, 0x14cc766, 0x4, 0x174d078, 0x0, 0x0, 0x5522, 0x13eb262, ...)
	/usr/local/Cellar/go/1.8.3/libexec/src/reflect/value.go:434 +0x91f
reflect.Value.Call(0x14b2560, 0xc420a17800, 0x693, 0x174d078, 0x0, 0x0, 0xc4203da840, 0xc4203da840, 0xc420976260)
	/usr/local/Cellar/go/1.8.3/libexec/src/reflect/value.go:302 +0xa4
text/template.(*state).evalCall(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0x14b2560, 0xc420a17800, 0x693, 0x1703d00, 0xc42016c660, 0x14e38dd, ...)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:668 +0x51f
text/template.(*state).evalField(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0x14e38dd, 0x8, 0x1703d00, 0xc42016c660, 0xc420014980, 0x1, ...)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:558 +0xe18
text/template.(*state).evalFieldChain(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0x14b2560, 0xc420a17800, 0x99, 0x1703d00, 0xc42016c660, 0xc420014850, ...)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:526 +0x22b
text/template.(*state).evalFieldNode(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0xc42016c660, 0xc420014980, 0x1, 0x1, 0x0, 0x0, ...)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:490 +0x118
text/template.(*state).evalCommand(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0xc42016c630, 0x0, 0x0, 0x0, 0x16, 0x3, ...)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:428 +0x837
text/template.(*state).evalPipeline(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0xc420168230, 0x0, 0xc42062f5c0, 0x10aeabb)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:406 +0xf2
text/template.(*state).walkRange(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0xc4201704c0)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:315 +0xec
text/template.(*state).walk(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0x1703fa0, 0xc4201704c0)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:243 +0x4f1
text/template.(*state).walk(0xc42062f7d8, 0x14b2560, 0xc420a17800, 0x99, 0x1703e20, 0xc420125470)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:240 +0x139
text/template.(*Template).execute(0xc42023a1c0, 0x16fda20, 0xc42000e018, 0x14b2560, 0xc420a17800, 0x0, 0x0)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:195 +0x20a
text/template.(*Template).Execute(0xc42023a1c0, 0x16fda20, 0xc42000e018, 0x14b2560, 0xc420a17800, 0x0, 0x0)
	/usr/local/Cellar/go/1.8.3/libexec/src/text/template/exec.go:178 +0x53
github.com/segmentio/cwlogs/cmd.fetch(0x172d5c0, 0xc420016e80, 0x1, 0x4, 0x0, 0x0)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/cmd/fetch.go:125 +0x537
github.com/segmentio/cwlogs/vendor/github.com/spf13/cobra.(*Command).execute(0x172d5c0, 0xc420016e40, 0x4, 0x4, 0x172d5c0, 0xc420016e40)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/spf13/cobra/command.go:650 +0x457
github.com/segmentio/cwlogs/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x172da40, 0x14d2a5b, 0x13, 0xc4200f9f68)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/spf13/cobra/command.go:729 +0x339
github.com/segmentio/cwlogs/vendor/github.com/spf13/cobra.(*Command).Execute(0x172da40, 0xc420010118, 0x0)
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/vendor/github.com/spf13/cobra/command.go:688 +0x2b
github.com/segmentio/cwlogs/cmd.Execute()
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/cmd/root.go:45 +0x31
main.main()
	/Users/stephenmathieson/dev/src/github.com/segmentio/cwlogs/main.go:6 +0x20

Are you using the latest version? I believe this was fixed a while back by #15

This just happened again. How do I check what version I'm using?

∴ cwlogs --version
unknown flag: --version

∴ cwlogs
Usage:
  cwlogs [flags]
  cwlogs [command]

Available Commands:
  fetch       fetch logs for a given service
  help        Help about any command
  list        list streams for a given service

Flags:
  -c, --color   Enable color output (default true)
  -h, --help    help for cwlogs

Use "cwlogs [command] --help" for more information about a command.

Yeah, no version flag to tell you. Safest bet would just be to upgrade. Easiest is probably just to get rid of your current version and grab the newest from our homebrew (there are also github releases on the releases page)

I just ended up pulling the changes and go installing. I think a nice addition could be supporting a -v/--version flag tho. Would be you be up for merging a PR adding support (using ldflags at build time)?

Yeah, go for it