{"id":"72a457cf99b98d37","repo":"go-redis/redis","slug":"failed-to-create-credentials-listener-w","errorCode":null,"errorMessage":"failed to create credentials listener: %w","messagePattern":"failed to create credentials listener: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"redis.go","lineNumber":746,"sourceCode":"\t// and to guard the user-visible OnConnect callback below.\n\tconn.baseClient.cscActive = c.cscActive\n\t// This internal conn's init pipeline issues CLIENT TRACKING ON itself;\n\t// exempt it from the guard that blocks user-issued CLIENT TRACKING. Setting\n\t// the field after newConn is safe: initHooks bound the pipeline hook as a\n\t// method value on the addressable baseClient, so the guard reads the\n\t// updated field.\n\tconn.baseClient.allowClientTracking = true\n\n\tusername, password := \"\", \"\"\n\tif c.opt.StreamingCredentialsProvider != nil {\n\t\tcredListener, initErr := c.streamingCredentialsManager.Listener(\n\t\t\tcn,\n\t\t\tc.reAuthConnection(),\n\t\t\tc.onAuthenticationErr(),\n\t\t)\n\t\tif initErr != nil {\n\t\t\tcn.GetStateMachine().Transition(pool.StateClosed)\n\t\t\treturn fmt.Errorf(\"failed to create credentials listener: %w\", initErr)\n\t\t}\n\n\t\tcredentials, unsubscribeFromCredentialsProvider, initErr := c.opt.StreamingCredentialsProvider.\n\t\t\tSubscribe(credListener)\n\t\tif initErr != nil {\n\t\t\tcn.GetStateMachine().Transition(pool.StateClosed)\n\t\t\treturn fmt.Errorf(\"failed to subscribe to streaming credentials: %w\", initErr)\n\t\t}\n\n\t\t// Per-connection unsubscribe is attached to the connection itself so it\n\t\t// runs when this specific connection is closed. Do not register it on\n\t\t// c.onClose: initConn runs for every (re)initialized connection, and\n\t\t// attaching per-connection state to the shared baseClient registry would\n\t\t// either leak entries (one per connection id, never trimmed) or — with\n\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","sourceCodeStart":728,"sourceCodeEnd":764,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/redis.go#L728-L764","documentation":"Error \"failed to create credentials listener: %w\" thrown in go-redis/redis.","triggerScenarios":"Thrown at redis.go:746 when the library encounters an invalid state.","commonSituations":"Validate credentials provider configuration at startup before constructing the client.","solutions":["Inspect the wrapped error from the credentials listener creation","Verify the streaming credentials provider is correctly configured (e.g. Entra ID setup)"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}