Panic when trying to use file consumer without stream configuration
mre opened this issue · 2 comments
Gollum version: Latest master, compiled with make
Operating system: Mac OS Sierra 10.12.5
Contents of file: gollum.conf:
input:
Type: consumer.File
File: foo
DefaultOffset: "Oldest"
output:
Type: producer.Console
Streams:
- test
Contents of file: foo:
foo
Command:
./gollum -c gollum.conf
Expected behavior:
Show error message. Something like:
"Missing 'Streams' parameter in plugin input
. At least one stream must be defined for every plugin."
Actual behavior:
Runtime panic.
Panic shutdown: runtime error: index out of range
.../go/src/github.com/trivago/gollum/vendor/github.com/trivago/tgo/runtime.go:61
/usr/local/opt/go/libexec/src/runtime/asm_amd64.s:514
/usr/local/opt/go/libexec/src/runtime/panic.go:489
/usr/local/opt/go/libexec/src/runtime/panic.go:28
.../go/src/github.com/trivago/gollum/core/simpleconsumer.go:216
.../go/src/github.com/trivago/gollum/core/simpleconsumer.go:182
.../go/src/github.com/trivago/gollum/consumer/file.go:121
.../go/src/github.com/trivago/gollum/consumer/file.go:188
.../go/src/github.com/trivago/gollum/vendor/github.com/trivago/tgo/tio/bufferedreader.go:267
.../go/src/github.com/trivago/gollum/consumer/file.go:231
Fix:
Define at least one stream.
input:
Type: consumer.File
File: foo
DefaultOffset: "Oldest"
Streams:
- test
output:
Type: producer.Console
Streams:
- test
Have not tested, but maybe the same bug occurs in other plugins.
OTOH, in some plugins, missing parameters simply cause an Error-level entry in the log, but they don't abort startup. It would be nice to harmonize this behavior. Maybe have Configure()
in the plugins (interface Configurable
) return an error value etc.
True. I'd rather err on the side of caution here and throw and error when the configuration is incomplete in any way. Consistent error behavior would be a big plus.