fix: fatal with clear message when keyvalue type is redis but redis is not enabled

Instead of panicking with a nil pointer dereference when keyvalue.type
is set to "redis" but redis.enabled is false, log a fatal error with a
clear, actionable message telling the user to enable redis.

Closes go-vikunja/vikunja#2608

https://claude.ai/code/session_01TRuPTGYDQjxqHRFWQaJGvy
This commit is contained in:
Claude
2026-04-12 09:08:12 +00:00
committed by kolaente
parent 3e59a654b5
commit 85cfadc5b0

View File

@@ -18,6 +18,7 @@ package keyvalue
import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/modules/keyvalue/memory"
"code.vikunja.io/api/pkg/modules/keyvalue/redis"
)
@@ -40,6 +41,9 @@ var store Storage
func InitStorage() {
switch config.KeyvalueType.GetString() {
case "redis":
if !config.RedisEnabled.GetBool() {
log.Fatalf("keyvalue.type is set to %q but redis is not enabled. Please set redis.enabled to true in your configuration.", config.KeyvalueType.GetString())
}
store = redis.NewStorage()
case "memory":
fallthrough