{"record":{"id":"4db12019e2c21d18","repo":"thanos-io/thanos","slug":"failed-to-create-redis-client","errorCode":null,"errorMessage":"failed to create redis client","messagePattern":"failed to create redis client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/cache/caching_bucket_factory.go","lineNumber":134,"sourceCode":"\t\t}\n\t\tc = cache.NewMemcachedCache(\"caching-bucket\", logger, memcached, reg)\n\tcase string(InMemoryBucketCacheProvider):\n\t\tc, err = cache.NewInMemoryCache(\"caching-bucket\", logger, reg, backendConfig)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to create inmemory cache\")\n\t\t}\n\tcase string(GroupcacheBucketCacheProvider):\n\t\tconst basePath = \"/_galaxycache/\"\n\n\t\tc, err = cache.NewGroupcache(logger, reg, backendConfig, basePath, r, bucket, cfg)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed to create groupcache\")\n\t\t}\n\n\tcase string(RedisBucketCacheProvider):\n\t\tredisCache, err := cacheutil.NewRedisClient(logger, \"caching-bucket\", backendConfig, reg)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to create redis client\")\n\t\t}\n\t\tc = cache.NewRedisCache(\"caching-bucket\", logger, redisCache, reg)\n\tdefault:\n\t\treturn nil, errors.Errorf(\"unsupported cache type: %s\", config.Type)\n\t}\n\n\t// Include interactions with cache in the traces.\n\tc = cache.NewTracingCache(c)\n\tcfg.SetCacheImplementation(c)\n\n\tcb, err := NewCachingBucket(bucket, cfg, logger, reg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn cb, nil\n}\n","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/cache/caching_bucket_factory.go#L116-L152","documentation":"When the cache type is REDIS, the factory constructs a Redis client via cacheutil.NewRedisClient; failures are wrapped as 'failed to create redis client'. Like the memcached path, this validates configuration (address, auth, timeouts) before any actual connection pool is exercised heavily.","triggerScenarios":"CachingWithBackendConfig.Type == REDIS and NewRedisClient returns an error: invalid or missing Redis address, bad auth config (username/password fields), invalid DB index, malformed timeout values, or an unrecognized client config field.","commonSituations":"Wrong REDIS address or port, Redis requiring auth but no credentials supplied, TLS settings mismatches, or mixing memcached-style config keys into a Redis cache entry.","solutions":["Verify the addresses field points at reachable Redis instances (host:port)","Add correct username/password/tls settings if Redis requires authentication","Check timeout and connection-pool fields parse as valid durations/ints","Inspect the wrapped inner error for the precise invalid parameter","Test connectivity with redis-cli -h <host> -p <port> from the Thanos pod"],"exampleFix":"// before\nconfig:\n  type: REDIS\n  redis:\n    addresses: \"6379\"            # missing host\ntimeout: soon                     # invalid duration\n// after\nconfig:\n  type: REDIS\n  redis:\n    addresses: \"redis.cache.svc:6379\"\ntimeout: 500ms","handlingStrategy":"validation","validationCode":"for _, a := range redisAddresses {\n    if _, _, err := net.SplitHostPort(a); err != nil { return fmt.Errorf(\"bad redis address %q: %w\", a, err) }\n}\nif _, err := time.ParseDuration(redisTimeout); err != nil { return fmt.Errorf(\"bad redis timeout: %w\", err) }","typeGuard":null,"tryCatchPattern":"cb, err := storecache.NewCachingBucketFromYaml(yamlContent, logger, reg, bucket, router)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to create redis client\") {\n        return fmt.Errorf(\"redis client config invalid (address/auth/timeouts): %w\", err)\n    }\n    return err\n}","preventionTips":["Pre-flight test redis-cli connectivity from the Thanos pod","Supply username/password/TLS when Redis requires auth","Use valid Go durations for timeout fields","Keep redis-specific keys under the REDIS cache entry only"],"tags":["go","redis","config","thanos"],"backgroundTag":"missing-required-config-field","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}