{"record":{"id":"608f41ebf056bcca","repo":"redis/go-redis","slug":"failed-to-resolve-credentials-w","errorCode":null,"errorMessage":"failed to resolve credentials: %w","messagePattern":"failed to resolve credentials: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"redis.go","lineNumber":890,"sourceCode":"\t\t// the pre-fix wrappedOnClose approach — build an unbounded closure chain\n\t\t// retaining every prior connection's unsubscribe (see issue #3772).\n\t\t//\n\t\t// Note: pool.Conn.SetOnClose OVERWRITES any prior callback (see the\n\t\t// doc on that method). That is safe here because the streaming\n\t\t// credentials Manager deduplicates listeners by connection id, so a\n\t\t// second initConn on the same cn re-Subscribes the SAME listener and\n\t\t// the returned unsubscribe is equivalent to the one already installed.\n\t\t// Any future code path that could hand out a distinct unsubscribe on\n\t\t// re-initialization must first invoke the existing one to avoid\n\t\t// orphaning the old subscription on the credentials provider.\n\t\tcn.SetOnClose(unsubscribeFromCredentialsProvider)\n\n\t\tusername, password = credentials.BasicAuth()\n\t} else {\n\t\tusername, password, initErr = c.opt.resolveCredentials(ctx)\n\t\tif initErr != nil {\n\t\t\tcn.GetStateMachine().Transition(pool.StateClosed)\n\t\t\treturn fmt.Errorf(\"failed to resolve credentials: %w\", initErr)\n\t\t}\n\t}\n\n\t// for redis-server versions that do not support the HELLO command,\n\t// RESP2 will continue to be used.\n\t// helloOK tracks whether HELLO succeeded. If it did not, the connection\n\t// falls back to RESP2 regardless of c.opt.Protocol, and features that\n\t// require RESP3 (e.g. maintenance notifications) must be skipped.\n\thelloOK := false\n\t// For redis-server versions that do not support HELLO, RESP2 continues to\n\t// be used. Remember that negotiated fallback: configured Protocol remains 3,\n\t// but CSC must not serve without RESP3 invalidations.\n\thelloFallbackToRESP2 := false\n\tif initErr = conn.Hello(ctx, c.opt.Protocol, username, password, c.opt.ClientName).Err(); initErr == nil {\n\t\t// Authentication successful with HELLO command\n\t\thelloOK = true\n\t} else if !isRedisError(initErr) {\n\t\t// When the server responds with the RESP protocol and the result is not a normal","sourceCodeStart":872,"sourceCodeEnd":908,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/redis.go#L872-L908","documentation":"Error \"failed to resolve credentials: %w\" thrown in redis/go-redis.","triggerScenarios":"Thrown at redis.go:890 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}