Skip to content

Commit 1940fae

Browse files
authored
Fix: next_token causing infinite loop in fetching Clusters (#1699)
**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.
1 parent 7986335 commit 1940fae

File tree

1 file changed

+2
-2
lines changed
  • sagemaker-core/src/sagemaker/core/utils

1 file changed

+2
-2
lines changed

sagemaker-core/src/sagemaker/core/utils/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,13 @@ def __next__(self) -> T:
445445
elif (
446446
len(self.summary_list) > 0
447447
and self.index >= len(self.summary_list)
448-
and self.next_token is None
448+
and (not self.next_token)
449449
):
450450
raise StopIteration
451451

452452
# Otherwise, get the next page of summaries by calling the list method with the next token if available
453453
else:
454-
if self.next_token is not None:
454+
if self.next_token:
455455
response = getattr(self.client, self.list_method)(
456456
NextToken=self.next_token, **self.list_method_kwargs
457457
)

0 commit comments

Comments
 (0)