From 2658648bc09af5a8a0c35aa690ac7c3da6771449 Mon Sep 17 00:00:00 2001 From: jzhaoqwa Date: Thu, 29 May 2025 13:37:34 -0700 Subject: [PATCH] Fix: next_token causing infinite loop in fetching Clusters **Description** next_token from API response is empty string, not None. The condition in StopIteration is incorrect **Testing Done** Test the fix locally and infinite loop is fixed. --- src/sagemaker_core/main/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sagemaker_core/main/utils.py b/src/sagemaker_core/main/utils.py index 39176128..126aa556 100644 --- a/src/sagemaker_core/main/utils.py +++ b/src/sagemaker_core/main/utils.py @@ -457,13 +457,13 @@ def __next__(self) -> T: elif ( len(self.summary_list) > 0 and self.index >= len(self.summary_list) - and self.next_token is None + and (not self.next_token) ): raise StopIteration # Otherwise, get the next page of summaries by calling the list method with the next token if available else: - if self.next_token is not None: + if self.next_token: response = getattr(self.client, self.list_method)( NextToken=self.next_token, **self.list_method_kwargs )