{"record":{"id":"cebea0c469d30651","repo":"juspay/hyperswitch","slug":"failed-to-publish-on-authenticated-connection","errorCode":null,"errorMessage":"failed to publish on authenticated connection","messagePattern":"failed to publish on authenticated connection","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/redis_interface/src/test.rs","lineNumber":2389,"sourceCode":"\n            let channel = format!(\"test_auth_pubsub_{}\", unique_test_id());\n            let test_message = \"authenticated_message\";\n\n            pool.redis_conn\n                .subscriber\n                .subscribe(&channel)\n                .await\n                .expect(\"failed to subscribe on authenticated connection\");\n\n            let mut receiver = pool.redis_conn.subscriber.message_rx();\n\n            tokio::time::sleep(std::time::Duration::from_millis(100)).await;\n\n            pool.redis_conn\n                .publisher\n                .publish(&channel, RedisValue::from_string(test_message.to_string()))\n                .await\n                .expect(\"failed to publish on authenticated connection\");\n\n            let received =\n                tokio::time::timeout(std::time::Duration::from_secs(5), receiver.recv()).await;\n\n            match received {\n                Ok(Ok(msg)) => {\n                    let value_str = redis_value_to_option_string(&msg.value);\n                    msg.channel == channel && value_str.as_deref() == Some(test_message)\n                }\n                _ => false,\n            }\n        })\n    })\n    .await\n    .expect(\"Spawn block failure\");\n\n    assert!(is_success);\n}","sourceCodeStart":2371,"sourceCodeEnd":2407,"githubUrl":"https://github.com/juspay/hyperswitch/blob/afd92843521ced2c6856b98ae4ea332e75102d88/crates/redis_interface/src/test.rs#L2371-L2407","documentation":"Panic from expect() on publisher.publish(&channel, RedisValue::from_string(...)) in test_authenticated_connection_pubsub (crates/redis_interface/src/test.rs:2389). The PUBLISH command on the authenticated publisher connection returned Err, aborting the test. Note this is the publish call itself failing, not the subscriber failing to receive (that path is handled by the timeout/match below).","triggerScenarios":"pool.redis_conn.publisher.publish(...) returns Err: publisher connection dropped/unauthenticated, Redis unreachable, or the publisher client was constructed for a different mode (cluster vs standalone) than the server.","commonSituations":"Redis restarted between subscribe and publish killing pooled connections; wrong password on the publisher half of the split conn; keyslot/cluster routing errors when publishing to a channel on a cluster node that doesn't serve it.","solutions":["Verify the authenticated connection pool is healthy before publish (the subscribe step just succeeded means creds are likely fine; check connection drop/reconnect handling).","Include the channel and underlying error in the panic message to diagnose; run redis-cli PUBLISH manually against the same server to confirm server-side health.","If publishing right after subscribe, keep the sleep(100ms) so the subscriber is ready, and confirm publish targets the same channel name/type (exact channel vs pattern).","For cluster deployments ensure the publisher uses cluster-aware routing instead of a single-node client."],"exampleFix":"// before\npool.redis_conn\n    .publisher\n    .publish(&channel, RedisValue::from_string(test_message.to_string()))\n    .await\n    .expect(\"failed to publish on authenticated connection\");\n// after\npool.redis_conn\n    .publisher\n    .publish(&channel, RedisValue::from_string(test_message.to_string()))\n    .await\n    .unwrap_or_else(|e| panic!(\"failed to publish to {channel}: {e:?}\"));","handlingStrategy":"try-catch","validationCode":"// ensure subscriber is ready before publishing:\ntokio::time::sleep(std::time::Duration::from_millis(100)).await;\n// and verify the channel string is identical on both sides:\nassert_eq!(subscriber_channel, publisher_channel);","typeGuard":null,"tryCatchPattern":"pool.redis_conn.publisher.publish(&channel, value).await\n    .unwrap_or_else(|e| panic!(\"failed to publish to {channel}: {e:?}\"));","preventionTips":["Keep the readiness sleep between subscribe and publish","Use the same channel name/type on subscriber and publisher","Check connection health after any Redis restart mid-test","Use cluster-aware publisher routing when targeting Redis cluster"],"tags":["redis","pubsub","publish","test-infrastructure","panic"],"backgroundTag":"connection-refused","analyzedSha":"afd92843521ced2c6856b98ae4ea332e75102d88","analyzedAt":"2026-09-18T01:18:02.947Z","contentChangedAt":"2026-09-18T01:18:02.947Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}