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

github-merge-queue[bot] pushed a commit to branch 
gh-readonly-queue/dev/pr-11586-3bff8dcc274d647343289b47784d53405b22b7d4
in repository https://gitbox.apache.org/repos/asf/seatunnel.git

commit 8ee7a0b8524d260464840fb619b646742ba70dce
Author: Sumit Asekar <[email protected]>
AuthorDate: Sat Nov 7 03:05:28 2026 +0000

    [Improve][Connector-V2] Validate MaxCompute sink retries with OptionRule 
(#11586)
    
    Co-authored-by: GitHub Agent <[email protected]>
    Co-authored-by: DanielLeens <[email protected]>
---
 docs/en/connectors/sink/Maxcompute.md              |  4 +-
 docs/zh/connectors/sink/Maxcompute.md              |  4 +-
 .../maxcompute/sink/MaxcomputeSinkFactory.java     | 13 +++-
 .../maxcompute/MaxcomputeSourceFactoryTest.java    | 85 ++++++++++++++++++----
 .../test/resources/maxcompute_to_maxcompute.conf   |  9 +--
 5 files changed, 91 insertions(+), 24 deletions(-)

diff --git a/docs/en/connectors/sink/Maxcompute.md 
b/docs/en/connectors/sink/Maxcompute.md
index 10b9ace2237..10e09a65ae0 100644
--- a/docs/en/connectors/sink/Maxcompute.md
+++ b/docs/en/connectors/sink/Maxcompute.md
@@ -230,7 +230,7 @@ Default: Not set (use default quota)
 
 ### retry_times [int]
 
-`retry_times` Maximum retry times for the ODPS REST client on transient 
failures. Default `4`.
+`retry_times` Maximum retry times for the ODPS REST client on transient 
failures. Must be a nonnegative integer; `0` is accepted. Negative values are 
rejected during configuration validation. Default `4`.
 
 ### tunnel_connect_timeout_ms [long]
 
@@ -242,7 +242,7 @@ Default: Not set (use default quota)
 
 ### tunnel_retry_times [int]
 
-`tunnel_retry_times` Maximum retry times for the Tunnel client on transient 
failures. Default `4`.
+`tunnel_retry_times` Maximum retry times for the Tunnel client on transient 
failures. Must be a nonnegative integer; `0` is accepted. Negative values are 
rejected during configuration validation. Default `4`.
 
 ### insert_strategy [string]
 
diff --git a/docs/zh/connectors/sink/Maxcompute.md 
b/docs/zh/connectors/sink/Maxcompute.md
index 7d9c7d1996b..af0b87f2f13 100644
--- a/docs/zh/connectors/sink/Maxcompute.md
+++ b/docs/zh/connectors/sink/Maxcompute.md
@@ -222,7 +222,7 @@ Tunnel Quota 允许您使用专用的计算资源进行 MaxCompute Tunnel 数据
 
 ### retry_times [int]
 
-`retry_times` ODPS REST 客户端在瞬态失败时的最大重试次数。默认 `4`。
+`retry_times` ODPS REST 客户端在瞬态失败时的最大重试次数。必须为非负整数,允许设置为 `0`。负数会在配置校验阶段被拒绝。默认 
`4`。
 
 ### tunnel_connect_timeout_ms [long]
 
@@ -234,7 +234,7 @@ Tunnel Quota 允许您使用专用的计算资源进行 MaxCompute Tunnel 数据
 
 ### tunnel_retry_times [int]
 
-`tunnel_retry_times` Tunnel 客户端在瞬态失败时的最大重试次数。默认 `4`。
+`tunnel_retry_times` Tunnel 客户端在瞬态失败时的最大重试次数。必须为非负整数,允许设置为 
`0`。负数会在配置校验阶段被拒绝。默认 `4`。
 
 ### insert_strategy [string]
 
diff --git 
a/seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/sink/MaxcomputeSinkFactory.java
 
b/seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/sink/MaxcomputeSinkFactory.java
index 96539e6f772..53bb80306d4 100644
--- 
a/seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/sink/MaxcomputeSinkFactory.java
+++ 
b/seatunnel-connectors-v2/connector-maxcompute/src/main/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/sink/MaxcomputeSinkFactory.java
@@ -17,6 +17,7 @@
 
 package org.apache.seatunnel.connectors.seatunnel.maxcompute.sink;
 
+import org.apache.seatunnel.api.configuration.util.Conditions;
 import org.apache.seatunnel.api.configuration.util.OptionRule;
 import org.apache.seatunnel.api.options.SinkConnectorCommonOptions;
 import org.apache.seatunnel.api.options.table.FormatOptions;
@@ -37,6 +38,10 @@ public class MaxcomputeSinkFactory implements 
TableSinkFactory {
         return MaxcomputeSinkOptions.PLUGIN_NAME;
     }
 
+    /**
+     * Declares sink retry bounds before client creation while retaining 
runtime guards for source
+     * and catalog entry points.
+     */
     @Override
     public OptionRule optionRule() {
         return OptionRule.builder()
@@ -60,11 +65,15 @@ public class MaxcomputeSinkFactory implements 
TableSinkFactory {
                         MaxcomputeSinkOptions.TUNNEL_NAME,
                         MaxcomputeSinkOptions.CONNECT_TIMEOUT_MS,
                         MaxcomputeSinkOptions.READ_TIMEOUT_MS,
-                        MaxcomputeSinkOptions.RETRY_TIMES,
                         MaxcomputeSinkOptions.TUNNEL_CONNECT_TIMEOUT_MS,
                         MaxcomputeSinkOptions.TUNNEL_READ_TIMEOUT_MS,
-                        MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES,
                         SinkConnectorCommonOptions.MULTI_TABLE_SINK_REPLICA)
+                .optional(
+                        MaxcomputeSinkOptions.RETRY_TIMES,
+                        
Conditions.greaterOrEqual(MaxcomputeSinkOptions.RETRY_TIMES, 0))
+                .optional(
+                        MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES,
+                        
Conditions.greaterOrEqual(MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES, 0))
                 .build();
     }
 
diff --git 
a/seatunnel-connectors-v2/connector-maxcompute/src/test/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/MaxcomputeSourceFactoryTest.java
 
b/seatunnel-connectors-v2/connector-maxcompute/src/test/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/MaxcomputeSourceFactoryTest.java
index da7474c2fb0..7ca08289754 100644
--- 
a/seatunnel-connectors-v2/connector-maxcompute/src/test/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/MaxcomputeSourceFactoryTest.java
+++ 
b/seatunnel-connectors-v2/connector-maxcompute/src/test/java/org/apache/seatunnel/connectors/seatunnel/maxcompute/MaxcomputeSourceFactoryTest.java
@@ -22,6 +22,7 @@ import org.apache.seatunnel.api.configuration.ReadonlyConfig;
 import org.apache.seatunnel.api.configuration.util.ConfigValidator;
 import org.apache.seatunnel.api.configuration.util.OptionRule;
 import org.apache.seatunnel.api.configuration.util.OptionValidationException;
+import 
org.apache.seatunnel.connectors.seatunnel.maxcompute.config.MaxcomputeSinkOptions;
 import 
org.apache.seatunnel.connectors.seatunnel.maxcompute.config.MaxcomputeSourceOptions;
 import 
org.apache.seatunnel.connectors.seatunnel.maxcompute.sink.MaxcomputeSinkFactory;
 import 
org.apache.seatunnel.connectors.seatunnel.maxcompute.source.MaxcomputeSourceFactory;
@@ -70,21 +71,44 @@ public class MaxcomputeSourceFactoryTest {
         assertInvalidEndpoint(config);
     }
 
-    private Map<String, Object> sourceConfig() {
-        Map<String, Object> config = new HashMap<>();
-        config.put(MaxcomputeSourceOptions.ENDPOINT.key(), 
"http://service.odps.aliyun.com/api";);
-        config.put(MaxcomputeSourceOptions.TABLE_NAME.key(), "test_table");
-        return config;
+    @Test
+    void acceptsSinkRetryDefaultsWhenAbsent() {
+        ReadonlyConfig config = ReadonlyConfig.fromMap(sinkConfig());
+
+        Assertions.assertDoesNotThrow(
+                () ->
+                        ConfigValidator.of(config)
+                                .validate(new 
MaxcomputeSinkFactory().optionRule()));
+        Assertions.assertEquals(4, 
config.get(MaxcomputeSinkOptions.RETRY_TIMES));
+        Assertions.assertEquals(4, 
config.get(MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES));
     }
 
-    private void assertInvalidEndpoint(Map<String, Object> config) {
-        OptionValidationException error =
-                Assertions.assertThrows(
-                        OptionValidationException.class,
-                        () ->
-                                
ConfigValidator.of(ReadonlyConfig.fromMap(config))
-                                        .validate(new 
MaxcomputeSourceFactory().optionRule()));
-        
Assertions.assertTrue(error.getMessage().contains(MaxcomputeSourceOptions.ENDPOINT.key()));
+    @ParameterizedTest
+    @ValueSource(ints = {0, 1, 4, Integer.MAX_VALUE})
+    void acceptsNonnegativeSinkRetryCountsWithoutChangingValues(int retries) {
+        Map<String, Object> options = sinkConfig();
+        options.put(MaxcomputeSinkOptions.RETRY_TIMES.key(), retries);
+        options.put(MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES.key(), retries);
+        ReadonlyConfig config = ReadonlyConfig.fromMap(options);
+
+        Assertions.assertDoesNotThrow(
+                () ->
+                        ConfigValidator.of(config)
+                                .validate(new 
MaxcomputeSinkFactory().optionRule()));
+        Assertions.assertEquals(retries, 
config.get(MaxcomputeSinkOptions.RETRY_TIMES));
+        Assertions.assertEquals(retries, 
config.get(MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES));
+    }
+
+    @ParameterizedTest
+    @ValueSource(ints = {-1, Integer.MIN_VALUE})
+    void rejectsNegativeSinkRestRetryCounts(int retries) {
+        assertInvalidSinkRetryCount(MaxcomputeSinkOptions.RETRY_TIMES, 
retries);
+    }
+
+    @ParameterizedTest
+    @ValueSource(ints = {-1, Integer.MIN_VALUE})
+    void rejectsNegativeSinkTunnelRetryCounts(int retries) {
+        assertInvalidSinkRetryCount(MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES, 
retries);
     }
 
     @Test
@@ -125,4 +149,39 @@ public class MaxcomputeSourceFactoryTest {
         Assertions.assertTrue(
                 optionalKeys.contains("tunnel_retry_times"), 
"tunnel_retry_times not registered");
     }
+
+    private Map<String, Object> sinkConfig() {
+        Map<String, Object> config = sourceConfig();
+        config.put(MaxcomputeSinkOptions.PROJECT.key(), "test_project");
+        return config;
+    }
+
+    private void assertInvalidSinkRetryCount(Option<Integer> option, int 
retries) {
+        Map<String, Object> config = sinkConfig();
+        config.put(option.key(), retries);
+        OptionValidationException error =
+                Assertions.assertThrows(
+                        OptionValidationException.class,
+                        () ->
+                                
ConfigValidator.of(ReadonlyConfig.fromMap(config))
+                                        .validate(new 
MaxcomputeSinkFactory().optionRule()));
+        Assertions.assertTrue(error.getMessage().contains(option.key()));
+    }
+
+    private Map<String, Object> sourceConfig() {
+        Map<String, Object> config = new HashMap<>();
+        config.put(MaxcomputeSourceOptions.ENDPOINT.key(), 
"http://service.odps.aliyun.com/api";);
+        config.put(MaxcomputeSourceOptions.TABLE_NAME.key(), "test_table");
+        return config;
+    }
+
+    private void assertInvalidEndpoint(Map<String, Object> config) {
+        OptionValidationException error =
+                Assertions.assertThrows(
+                        OptionValidationException.class,
+                        () ->
+                                
ConfigValidator.of(ReadonlyConfig.fromMap(config))
+                                        .validate(new 
MaxcomputeSourceFactory().optionRule()));
+        
Assertions.assertTrue(error.getMessage().contains(MaxcomputeSourceOptions.ENDPOINT.key()));
+    }
 }
diff --git 
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_to_maxcompute.conf
 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_to_maxcompute.conf
index f64d5950279..f874cde92ae 100644
--- 
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_to_maxcompute.conf
+++ 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_to_maxcompute.conf
@@ -72,13 +72,12 @@ sink {
     table_name = "test_table_sink"
     insert_strategy = "upsert"
 
-    # Non-default but safe values to prove the options are applied in a real 
job,
-    # not just accepted by OptionRule validation.
+    # Explicit overrides exercise timeouts and accepted zero retry counts in a 
real job.
     connect_timeout_ms = 15000
     read_timeout_ms = 121000
-    retry_times = 5
+    retry_times = 0
     tunnel_connect_timeout_ms = 181000
     tunnel_read_timeout_ms = 301000
-    tunnel_retry_times = 5
+    tunnel_retry_times = 0
   }
-}
\ No newline at end of file
+}

Reply via email to