{"record":{"id":"53880f90350406e2","repo":"thanos-io/thanos","slug":"converting-ping-response-to-string","errorCode":null,"errorMessage":"converting PING response to string","messagePattern":"converting PING response to string","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cortex/chunk/cache/redis_client.go","lineNumber":98,"sourceCode":"\n\treturn &RedisClient{\n\t\texpiration: cfg.Expiration,\n\t\ttimeout:    cfg.Timeout,\n\t\trdb:        client,\n\t}, nil\n}\n\nfunc (c *RedisClient) Ping(ctx context.Context) error {\n\tvar cancel context.CancelFunc\n\tif c.timeout > 0 {\n\t\tctx, cancel = context.WithTimeout(ctx, c.timeout)\n\t\tdefer cancel()\n\t}\n\n\tresp := c.rdb.Do(ctx, c.rdb.B().Ping().Build())\n\tpingResp, err := resp.ToString()\n\tif err != nil {\n\t\treturn errors.New(\"converting PING response to string\")\n\t}\n\tif pingResp != \"PONG\" {\n\t\treturn errors.Errorf(\"redis: Unexpected PING response %q\", pingResp)\n\t}\n\treturn nil\n}\n\nfunc (c *RedisClient) MSet(ctx context.Context, keys []string, values [][]byte) error {\n\tvar cancel context.CancelFunc\n\tif c.timeout > 0 {\n\t\tctx, cancel = context.WithTimeout(ctx, c.timeout)\n\t\tdefer cancel()\n\t}\n\n\tif len(keys) != len(values) {\n\t\treturn errors.Errorf(\"MSet the length of keys and values not equal, len(keys)=%d, len(values)=%d\", len(keys), len(values))\n\t}\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/internal/cortex/chunk/cache/redis_client.go#L80-L116","documentation":"RedisClient.Ping issues the PING command via rueidis and must convert the reply to a string. If resp.ToString() returns an error (reply is not a simple string), the client returns this fixed error instead of the raw conversion error.","triggerScenarios":"Calling Ping() when the server replies to PING with a non-string type — typically a protocol-level error reply (e.g. NOAUTH, loading dataset) that rueidis returns as a non-string message.","commonSituations":"Redis requiring auth (requirepass set, no password sent); Redis still loading its RDB/AOF and replying with LOADING errors; connecting to a non-Redis service on the port.","solutions":["Configure the Redis password/credentials if the server requires AUTH.","Wait for Redis to finish loading or check server logs (LOADING Redis is loading the dataset in memory).","Verify the endpoint actually points at a Redis server speaking RESP.","Retry the ping once the server is healthy."],"exampleFix":"// before: no auth configured, PING returns NOAUTH\nredis:\n  endpoint: redis:6379\n// after\nredis:\n  endpoint: redis:6379\n  password: ${REDIS_PASSWORD}","handlingStrategy":"try-catch","validationCode":"if err := redisClient.Ping(ctx); err != nil { return fmt.Errorf(\"redis not ready: %w\", err) }","typeGuard":null,"tryCatchPattern":"if err := client.Ping(ctx); err != nil {\n    if strings.Contains(err.Error(), \"converting PING response\") {\n        // likely NOAUTH or LOADING — check auth config / wait for load\n    }\n    return err\n}","preventionTips":["Configure Redis credentials whenever requirepass is set.","Add readiness gates that wait for Redis to leave LOADING state.","Verify the endpoint speaks RESP before wiring it in."],"tags":["redis","ping","protocol"],"backgroundTag":"unexpected-response-shape","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"}