This is an automated email from the ASF dual-hosted git repository.

piotr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/master by this push:
     new 11073ca80 fix(sdk): add leader redirection logic for 
`login_with_personal_access_token` (#2752)
11073ca80 is described below

commit 11073ca807ed3f7588b62605b2675cd803d2ef62
Author: Chengxi Luo <[email protected]>
AuthorDate: Tue Feb 17 03:00:01 2026 -0500

    fix(sdk): add leader redirection logic for 
`login_with_personal_access_token` (#2752)
    
    Closes #2751
---
 .../src/clients/binary_personal_access_tokens.rs   | 30 +++++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/core/sdk/src/clients/binary_personal_access_tokens.rs 
b/core/sdk/src/clients/binary_personal_access_tokens.rs
index 922995fa8..91e4ba760 100644
--- a/core/sdk/src/clients/binary_personal_access_tokens.rs
+++ b/core/sdk/src/clients/binary_personal_access_tokens.rs
@@ -16,14 +16,15 @@
  * under the License.
  */
 
-use crate::prelude::IggyClient;
+use crate::prelude::{ClientWrapper, IggyClient};
 use async_trait::async_trait;
-use iggy_binary_protocol::PersonalAccessTokenClient;
+use iggy_binary_protocol::{Client, PersonalAccessTokenClient};
 use iggy_common::locking::IggyRwLockFn;
 use iggy_common::{
     IdentityInfo, IggyError, PersonalAccessTokenExpiry, 
PersonalAccessTokenInfo,
     RawPersonalAccessToken,
 };
+use tracing::info;
 
 #[async_trait]
 impl PersonalAccessTokenClient for IggyClient {
@@ -55,10 +56,31 @@ impl PersonalAccessTokenClient for IggyClient {
         &self,
         token: &str,
     ) -> Result<IdentityInfo, IggyError> {
-        self.client
+        let identity = self
+            .client
             .read()
             .await
             .login_with_personal_access_token(token)
-            .await
+            .await?;
+
+        let should_redirect = {
+            let client = self.client.read().await;
+            match &*client {
+                ClientWrapper::Tcp(tcp_client) => 
tcp_client.handle_leader_redirection().await?,
+                ClientWrapper::Quic(quic_client) => 
quic_client.handle_leader_redirection().await?,
+                ClientWrapper::WebSocket(ws_client) => {
+                    ws_client.handle_leader_redirection().await?
+                }
+                _ => false,
+            }
+        };
+
+        if should_redirect {
+            info!("Redirected to leader, reconnecting and re-authenticating");
+            self.connect().await?;
+            self.login_with_personal_access_token(token).await
+        } else {
+            Ok(identity)
+        }
     }
 }

Reply via email to