DataDog / kvexpress

## Auto-archived due to inactivity. ## Go program to move data in and out of Consul's KV store.
Apache License 2.0
128 stars 13 forks source link

If you're using compression... #92

Closed darron closed 8 years ago

darron commented 8 years ago

...and you're reading a blank key - a key with no data - it panics - I think when it tries to decompress it.

Here's the error message:

[staging]darron@i-1dc56ea3:/etc/consul-template/special-config# kvexpress out -k does-not-exist -f /etc/will-not-write -l 1 -c 00644 -d true -z true
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x290 pc=0x5b5fc3]

goroutine 1 [running]:
panic(0x8af3c0, 0xc82000c0f0)
    /opt/go/src/runtime/panic.go:464 +0x3e6
io/ioutil.readAll.func1(0xc820045898)
    /opt/go/src/io/ioutil/ioutil.go:30 +0x11e
panic(0x8af3c0, 0xc82000c0f0)
    /opt/go/src/runtime/panic.go:426 +0x4e9
compress/gzip.(*Reader).Read(0x0, 0xc820114000, 0x200, 0x200, 0x200, 0x0, 0x0)
    /opt/go/src/compress/gzip/gunzip.go:262 +0x43
bytes.(*Buffer).ReadFrom(0xc8200457f0, 0x7fd695a450d8, 0x0, 0x0, 0x0, 0x0)
    /opt/go/src/bytes/buffer.go:176 +0x23f
io/ioutil.readAll(0x7fd695a450d8, 0x0, 0x200, 0x0, 0x0, 0x0, 0x0, 0x0)
    /opt/go/src/io/ioutil/ioutil.go:33 +0x156
io/ioutil.ReadAll(0x7fd695a450d8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /opt/go/src/io/ioutil/ioutil.go:42 +0x51
github.com/DataDog/kvexpress/commands.DecompressData(0x0, 0x0, 0x0, 0x0)
    /home/darron/go/src/github.com/DataDog/kvexpress/commands/util.go:139 +0x177
github.com/DataDog/kvexpress/commands.outRun(0xbb5aa0, 0xc8200c8180, 0x2, 0xc)
    /home/darron/go/src/github.com/DataDog/kvexpress/commands/out.go:61 +0x5f1
github.com/spf13/cobra.(*Command).execute(0xbb5aa0, 0xc8200c80c0, 0xc, 0xc, 0x0, 0x0)
    /home/darron/go/src/github.com/spf13/cobra/command.go:569 +0x85a
github.com/spf13/cobra.(*Command).ExecuteC(0xbb5ea0, 0xbb5aa0, 0x0, 0x0)
    /home/darron/go/src/github.com/spf13/cobra/command.go:656 +0x55c
github.com/spf13/cobra.(*Command).Execute(0xbb5ea0, 0x0, 0x0)
    /home/darron/go/src/github.com/spf13/cobra/command.go:615 +0x2d
main.main()
    /home/darron/go/src/github.com/DataDog/kvexpress/main.go:45 +0x714

If you're not using compression it doesn't fail like this - must test to make sure there's data in order to decompress it.