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-13069-60e039a810844323172d4048f721bc88146e9a83
in repository https://gitbox.apache.org/repos/asf/seatunnel.git

commit 8720821d10349e7c3041b6a8a63933320e0b7098
Author: 박재홍 <[email protected]>
AuthorDate: Thu Nov 26 05:25:14 2026 +0000

    [Improve][Connector-V2][MaxCompute] Validate nonblank sink endpoint (#13069)
---
 docs/en/connectors/sink/Maxcompute.md              |  2 +
 docs/zh/connectors/sink/Maxcompute.md              |  2 +
 .../maxcompute/sink/MaxcomputeSinkFactory.java     |  4 +-
 .../maxcompute/MaxcomputeSourceFactoryTest.java    | 55 +++++++++++++++++
 .../e2e/connector/maxcompute/MaxComputeIT.java     | 45 ++++++++++++++
 .../resources/maxcompute_sink_blank_endpoint.conf  | 70 ++++++++++++++++++++++
 .../resources/maxcompute_sink_valid_endpoint.conf  | 70 ++++++++++++++++++++++
 7 files changed, 246 insertions(+), 2 deletions(-)

diff --git a/docs/en/connectors/sink/Maxcompute.md 
b/docs/en/connectors/sink/Maxcompute.md
index 71501e24b4..caa362125c 100644
--- a/docs/en/connectors/sink/Maxcompute.md
+++ b/docs/en/connectors/sink/Maxcompute.md
@@ -74,6 +74,8 @@ or upsert session selected by `insert_strategy`.
 
 `endpoint` Your Maxcompute endpoint start with http.
 
+This required option must not be empty or whitespace-only. The option rule 
validates nonblank values without trimming or rewriting them; URL parsing and 
connectivity checks remain part of runtime initialization.
+
 ### project [string]
 
 `project` Your Maxcompute project which is created in Alibaba Cloud.
diff --git a/docs/zh/connectors/sink/Maxcompute.md 
b/docs/zh/connectors/sink/Maxcompute.md
index 1bc540e317..805523274c 100644
--- a/docs/zh/connectors/sink/Maxcompute.md
+++ b/docs/zh/connectors/sink/Maxcompute.md
@@ -70,6 +70,8 @@ import ChangeLog from '../changelog/connector-maxcompute.md';
 
 `endpoint` 您的 Maxcompute endpoint,以 http 开头。
 
+此必填选项不能为空字符串或仅包含空白字符。选项规则校验不会裁剪或改写非空白值;URL 解析和连接检查仍在运行时初始化阶段进行。
+
 ### project [string]
 
 `project` 您在阿里云中创建的 Maxcompute 项目。
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 53bb80306d..833b7d1043 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
@@ -47,8 +47,8 @@ public class MaxcomputeSinkFactory implements 
TableSinkFactory {
         return OptionRule.builder()
                 .required(
                         MaxcomputeSinkOptions.ENDPOINT,
-                        MaxcomputeSinkOptions.PROJECT,
-                        MaxcomputeSinkOptions.TABLE_NAME)
+                        Conditions.notBlank(MaxcomputeSinkOptions.ENDPOINT))
+                .required(MaxcomputeSinkOptions.PROJECT, 
MaxcomputeSinkOptions.TABLE_NAME)
                 .optional(
                         MaxcomputeSinkOptions.ACCESS_ID,
                         MaxcomputeSinkOptions.ACCESS_KEY,
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 7ca0828975..8744d2ef9d 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
@@ -111,6 +111,61 @@ public class MaxcomputeSourceFactoryTest {
         assertInvalidSinkRetryCount(MaxcomputeSinkOptions.TUNNEL_RETRY_TIMES, 
retries);
     }
 
+    @ParameterizedTest
+    @ValueSource(
+            strings = {
+                "http://service.odps.aliyun.com/api";,
+                " \thttp://service.odps.aliyun.com/api\r\n "
+            })
+    void acceptsNonblankSinkEndpointWithoutTrimming(String endpoint) {
+        Map<String, Object> config = sinkConfig();
+        config.put(MaxcomputeSinkOptions.ENDPOINT.key(), endpoint);
+        ReadonlyConfig readonlyConfig = ReadonlyConfig.fromMap(config);
+
+        Assertions.assertDoesNotThrow(
+                () ->
+                        ConfigValidator.of(readonlyConfig)
+                                .validate(new 
MaxcomputeSinkFactory().optionRule()));
+        Assertions.assertEquals(endpoint, 
readonlyConfig.get(MaxcomputeSinkOptions.ENDPOINT));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {"endpoint", "project", "table_name"})
+    void rejectsMissingRequiredSinkOption(String key) {
+        Map<String, Object> config = sinkConfig();
+        config.remove(key);
+        OptionValidationException error =
+                Assertions.assertThrows(
+                        OptionValidationException.class,
+                        () ->
+                                
ConfigValidator.of(ReadonlyConfig.fromMap(config))
+                                        .validate(new 
MaxcomputeSinkFactory().optionRule()));
+        Assertions.assertTrue(error.getMessage().contains(key), 
error.getMessage());
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {"", " ", "\t", "\n", "\r", " \t\r\n "})
+    void rejectsBlankSinkEndpoint(String endpoint) {
+        Map<String, Object> config = sinkConfig();
+        config.put(MaxcomputeSinkOptions.ENDPOINT.key(), endpoint);
+        OptionValidationException error =
+                Assertions.assertThrows(
+                        OptionValidationException.class,
+                        () ->
+                                
ConfigValidator.of(ReadonlyConfig.fromMap(config))
+                                        .validate(new 
MaxcomputeSinkFactory().optionRule()));
+        Assertions.assertTrue(error.getMessage().contains("endpoint"), 
error.getMessage());
+        Assertions.assertTrue(error.getMessage().contains("blank"), 
error.getMessage());
+    }
+
+    private Map<String, Object> sinkConfig() {
+        Map<String, Object> config = new HashMap<>();
+        config.put(MaxcomputeSinkOptions.ENDPOINT.key(), 
"http://service.odps.aliyun.com/api";);
+        config.put(MaxcomputeSinkOptions.PROJECT.key(), "test_project");
+        config.put(MaxcomputeSinkOptions.TABLE_NAME.key(), "test_table");
+        return config;
+    }
+
     @Test
     void optionRule() {
         Assertions.assertNotNull((new MaxcomputeSourceFactory()).optionRule());
diff --git 
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/java/org/apache/seatunnel/e2e/connector/maxcompute/MaxComputeIT.java
 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/java/org/apache/seatunnel/e2e/connector/maxcompute/MaxComputeIT.java
index 009731da17..11cbba4ec1 100644
--- 
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/java/org/apache/seatunnel/e2e/connector/maxcompute/MaxComputeIT.java
+++ 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/java/org/apache/seatunnel/e2e/connector/maxcompute/MaxComputeIT.java
@@ -25,7 +25,10 @@ import 
org.apache.seatunnel.api.table.factory.TableSourceFactoryContext;
 import 
org.apache.seatunnel.connectors.seatunnel.maxcompute.source.MaxcomputeSourceFactory;
 import org.apache.seatunnel.e2e.common.TestResource;
 import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
 import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+import org.apache.seatunnel.e2e.common.util.ContainerUtil;
 
 import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterAll;
@@ -67,6 +70,48 @@ import java.util.stream.Stream;
 @Slf4j
 public class MaxComputeIT extends TestSuiteBase implements TestResource {
 
+    @TestTemplate
+    @DisabledOnContainer(
+            value = {},
+            type = {EngineType.FLINK, EngineType.SPARK},
+            disabledReason = "The configuration-only --check command is 
provided by Zeta")
+    public void rejectsBlankSinkEndpointDuringConfigCheck(TestContainer 
container)
+            throws IOException, InterruptedException {
+        Container.ExecResult result =
+                checkSinkEndpoint(container, 
"/maxcompute_sink_blank_endpoint.conf");
+        String output = result.getStdout() + result.getStderr();
+        Assertions.assertNotEquals(0, result.getExitCode(), output);
+        Assertions.assertTrue(output.contains("endpoint") && 
output.contains("blank"), output);
+    }
+
+    @TestTemplate
+    @DisabledOnContainer(
+            value = {},
+            type = {EngineType.FLINK, EngineType.SPARK},
+            disabledReason = "The configuration-only --check command is 
provided by Zeta")
+    public void acceptsValidSinkEndpointDuringConfigCheck(TestContainer 
container)
+            throws IOException, InterruptedException {
+        Container.ExecResult result =
+                checkSinkEndpoint(container, 
"/maxcompute_sink_valid_endpoint.conf");
+        Assertions.assertEquals(0, result.getExitCode(), result.getStdout() + 
result.getStderr());
+    }
+
+    private Container.ExecResult checkSinkEndpoint(TestContainer container, 
String configResource)
+            throws IOException, InterruptedException {
+        container.executeExtraCommands(
+                engineContainer ->
+                        ContainerUtil.copyConnectorJarToContainer(
+                                engineContainer,
+                                configResource,
+                                "seatunnel-connectors-v2",
+                                "connector-",
+                                "seatunnel",
+                                "/tmp/seatunnel"));
+        String configPath = "/tmp/seatunnel/config" + configResource;
+        container.copyFileToContainer(configResource, configPath);
+        return container.executeBaseCommand(new String[] {"--config", 
configPath, "--check"});
+    }
+
     private GenericContainer<?> maxcompute;
 
     private static final int HOST_PORT = 8080;
diff --git 
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_sink_blank_endpoint.conf
 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_sink_blank_endpoint.conf
new file mode 100644
index 0000000000..0c99969a72
--- /dev/null
+++ 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_sink_blank_endpoint.conf
@@ -0,0 +1,70 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######
+###### This config file is a demonstration of batch processing in SeaTunnel 
config
+######
+
+env {
+  parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  FakeSource {
+    tables_configs = [
+      {
+        schema = {
+          table = "test_table_sink"
+          fields {
+            ID = int
+            NAME = string
+            AGE = int
+          }
+        }
+        rows = [
+          {
+            kind = INSERT
+            fields = [1, "INSERT_TEST1", 20]
+          }
+          {
+            kind = INSERT
+            fields = [2, "INSERT_TEST2", 30]
+          }
+          {
+            kind = INSERT
+            fields = [3, "INSERT_TEST3", 40]
+          }
+        ]
+      }
+    ]
+  }
+}
+
+transform {
+}
+
+sink {
+  Maxcompute {
+    accessId = "ak"
+    accesskey = "sk"
+    endpoint = " \t\r\n "
+    tunnel_endpoint = "http://maxcompute:8080";
+    project = "mocked_mc"
+    table_name = "test_table_sink"
+  }
+}
\ No newline at end of file
diff --git 
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_sink_valid_endpoint.conf
 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_sink_valid_endpoint.conf
new file mode 100644
index 0000000000..b33c2e27a8
--- /dev/null
+++ 
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-maxcompute-e2e/src/test/resources/maxcompute_sink_valid_endpoint.conf
@@ -0,0 +1,70 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+######
+###### This config file is a demonstration of batch processing in SeaTunnel 
config
+######
+
+env {
+  parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  FakeSource {
+    tables_configs = [
+      {
+        schema = {
+          table = "test_table_sink"
+          fields {
+            ID = int
+            NAME = string
+            AGE = int
+          }
+        }
+        rows = [
+          {
+            kind = INSERT
+            fields = [1, "INSERT_TEST1", 20]
+          }
+          {
+            kind = INSERT
+            fields = [2, "INSERT_TEST2", 30]
+          }
+          {
+            kind = INSERT
+            fields = [3, "INSERT_TEST3", 40]
+          }
+        ]
+      }
+    ]
+  }
+}
+
+transform {
+}
+
+sink {
+  Maxcompute {
+    accessId = "ak"
+    accesskey = "sk"
+    endpoint = "http://maxcompute:8080";
+    tunnel_endpoint = "http://maxcompute:8080";
+    project = "mocked_mc"
+    table_name = "test_table_sink"
+  }
+}
\ No newline at end of file

Reply via email to