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

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new b1ce34211 fix(aliyun): reject an incomplete cloud instance catalog 
page (#6085)
b1ce34211 is described below

commit b1ce34211a71b9ef57beedbe95b70251c3327145
Author: Apulupie <[email protected]>
AuthorDate: Fri Nov 27 12:55:13 2026 +0800

    fix(aliyun): reject an incomplete cloud instance catalog page (#6085)
---
 .../studio/provider/alibaba/AliyunCatalogService.java     | 15 ++++++++++++---
 .../studio/provider/alibaba/AliyunCatalogServiceTest.java | 11 +++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git 
a/server/src/main/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogService.java
 
b/server/src/main/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogService.java
index 0d7bbcb0c..10c788b68 100644
--- 
a/server/src/main/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogService.java
+++ 
b/server/src/main/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogService.java
@@ -142,15 +142,19 @@ public class AliyunCatalogService implements 
CloudCatalogProvider {
                     ListInstancesResponseBody::getMessage);
             ListInstancesResponseBody.Data data = body.getData();
             List<ListInstancesResponseBody.List> list = data == null ? null : 
data.getList();
-            if (list == null || list.isEmpty()) {
+            Long totalCount = data == null ? null : data.getTotalCount();
+            int returned = list == null ? 0 : list.size();
+            if (isIncompletePage((long) (page - 1) * 
AliyunConverters.PAGE_SIZE, returned, totalCount)) {
+                throw new BusinessException(502, "Aliyun instance catalog 
returned an incomplete page");
+            }
+            if (returned == 0) {
                 break;
             }
             all.addAll(list);
-            Long totalCount = data.getTotalCount();
             if (totalCount != null && totalCount < 0) {
                 throw new BusinessException(502, "Aliyun instance catalog 
returned a negative totalCount");
             }
-            if (list.size() < AliyunConverters.PAGE_SIZE
+            if (returned < AliyunConverters.PAGE_SIZE
                     || totalCount != null && all.size() >= totalCount
                     || totalCount == null && page >= 
AliyunConverters.MAX_PAGES) {
                 break;
@@ -159,6 +163,11 @@ public class AliyunCatalogService implements 
CloudCatalogProvider {
         return all;
     }
 
+    private static boolean isIncompletePage(long offset, int returned, Long 
totalCount) {
+        return totalCount != null && totalCount >= 0L
+                && returned < AliyunConverters.PAGE_SIZE && offset + returned 
< totalCount;
+    }
+
     private static boolean matchesSearch(String search, CloudInstanceOptionVO 
vo) {
         if (search == null || search.isBlank()) {
             return true;
diff --git 
a/server/src/test/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogServiceTest.java
 
b/server/src/test/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogServiceTest.java
index 4e5fbd57b..9568e6b39 100644
--- 
a/server/src/test/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogServiceTest.java
+++ 
b/server/src/test/java/org/apache/rocketmq/studio/provider/alibaba/AliyunCatalogServiceTest.java
@@ -241,6 +241,17 @@ class AliyunCatalogServiceTest {
                 .isEqualTo(400);
     }
 
+    @Test
+    void 
listCloudInstancesShouldRejectIncompletePageWhenTotalCountRequiresMoreTest() {
+        when(clientFactory.call(eq(CREDENTIAL_ID), eq(REGION), any()))
+                .thenReturn(instancesResponse(List.of(instanceRow("rmq-a", 
"A")), 2L));
+
+        assertThatThrownBy(() -> service.listCloudInstances(CREDENTIAL_ID, 
REGION, null))
+                .isInstanceOf(BusinessException.class)
+                .extracting("code")
+                .isEqualTo(502);
+    }
+
     @Test
     void getCloudInstanceShouldMapEndpointsTest() {
         GetInstanceResponse response = GetInstanceResponse.create().toBuilder()

Reply via email to