Open francislavoie opened 3 weeks ago
Nope I'm dumb, the config value for db
just wasn't set (missing env var, my fault) so the slice was empty. Whoops.
Either way, it shouldn't panic on bad config. It should be adjusted to properly report an error saying there's no input.
Thanks for the report @francislavoie, the caddyfile unmarshalling code attempts to handle properties with single or multiple values (in a nested block):
var configVal []string
if d.NextArg() {
// configuration item with single parameter
configVal = append(configVal, d.Val())
} else {
// configuration item with nested parameter list
for nesting := d.Nesting(); d.NextBlock(nesting); {
configVal = append(configVal, d.Val())
}
}
but subsequent code does not check if any values were supplied. I will look at updating the above block to check for conditions where parameter values are not supplied and handle the error gracefully.
My config is just:
The problem is here:
https://github.com/pberkel/caddy-storage-redis/blob/739937ec7e63f88437782b2f312cd25e31e9ba90/caddyfile.go#L85
Why are we doing
configVal[0]
?d.Val()
wouldn't be returning a slice, it returns a single token value. Pretty sure it should just beconfigVal
with no[0]
.