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-12180-30474f8632a88b7cc7116f0abd8e8eb83ad80f0a
in repository https://gitbox.apache.org/repos/asf/seatunnel.git

commit 271f73324dc4ef26f391925d6251009098717850
Author: Nikhil kumar <[email protected]>
AuthorDate: Tue Sep 8 05:28:08 2026 +0000

    [Improve][Connector-V2] Validate Web3j source URL (#12180)
---
 docs/en/connectors/source/Web3j.md                 |  2 +
 docs/zh/connectors/source/Web3j.md                 |  2 +
 .../seatunnel/source/Web3jSourceFactory.java       |  3 +-
 .../connectors/seatunnel/Web3jFactoryTest.java     | 74 ++++++++++++++++++++++
 4 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/docs/en/connectors/source/Web3j.md 
b/docs/en/connectors/source/Web3j.md
index 90b1a3b77e..d3a9c8234c 100644
--- a/docs/en/connectors/source/Web3j.md
+++ b/docs/en/connectors/source/Web3j.md
@@ -38,6 +38,8 @@ of the configured provider.
 |------|--------|----------|---------|-------------|
 | url  | String | Yes      | -       | Web3 provider endpoint used to 
communicate with the Ethereum network, for example an Infura URL. |
 
+The required `url` must not be empty or whitespace-only.
+
 ## Output Schema
 
 | Field | Type   | Description |
diff --git a/docs/zh/connectors/source/Web3j.md 
b/docs/zh/connectors/source/Web3j.md
index f142778a3b..f8f4b44aa6 100644
--- a/docs/zh/connectors/source/Web3j.md
+++ b/docs/zh/connectors/source/Web3j.md
@@ -35,6 +35,8 @@ Web3j 源连接器用于通过 Web3 服务端点读取区块链数据。目前
 |--------|------|------|--------|------|
 | url | String | 是 | - | 用于和以太坊网络通信的 Web3 服务端点,例如 Infura URL。 |
 
+必填项 `url` 不能为空字符串或仅包含空白字符。
+
 ## 输出字段
 
 | 字段 | 类型 | 描述 |
diff --git 
a/seatunnel-connectors-v2/connector-web3j/src/main/java/org/apache/seatunnel/connectors/seatunnel/source/Web3jSourceFactory.java
 
b/seatunnel-connectors-v2/connector-web3j/src/main/java/org/apache/seatunnel/connectors/seatunnel/source/Web3jSourceFactory.java
index 6c02dc8d11..6107a12cd9 100644
--- 
a/seatunnel-connectors-v2/connector-web3j/src/main/java/org/apache/seatunnel/connectors/seatunnel/source/Web3jSourceFactory.java
+++ 
b/seatunnel-connectors-v2/connector-web3j/src/main/java/org/apache/seatunnel/connectors/seatunnel/source/Web3jSourceFactory.java
@@ -29,6 +29,7 @@ import com.google.auto.service.AutoService;
 
 import java.io.Serializable;
 
+import static org.apache.seatunnel.api.configuration.util.Conditions.notBlank;
 import static 
org.apache.seatunnel.connectors.seatunnel.config.Web3jSourceOptions.URL;
 
 @AutoService(Factory.class)
@@ -40,7 +41,7 @@ public class Web3jSourceFactory implements TableSourceFactory 
{
 
     @Override
     public OptionRule optionRule() {
-        return OptionRule.builder().required(URL).build();
+        return OptionRule.builder().required(URL, notBlank(URL)).build();
     }
 
     @Override
diff --git 
a/seatunnel-connectors-v2/connector-web3j/src/test/java/org/apache/seatunnel/connectors/seatunnel/Web3jFactoryTest.java
 
b/seatunnel-connectors-v2/connector-web3j/src/test/java/org/apache/seatunnel/connectors/seatunnel/Web3jFactoryTest.java
new file mode 100644
index 0000000000..829f80fed5
--- /dev/null
+++ 
b/seatunnel-connectors-v2/connector-web3j/src/test/java/org/apache/seatunnel/connectors/seatunnel/Web3jFactoryTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel;
+
+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.source.Web3jSourceFactory;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+import java.util.Map;
+
+class Web3jFactoryTest {
+
+    private final OptionRule optionRule = new 
Web3jSourceFactory().optionRule();
+
+    @Test
+    void testNonblankUrlAccepted() {
+        for (String url :
+                new String[] {
+                    "http://localhost:8545";, "https://example.com";, " 
custom-endpoint "
+                }) {
+            Assertions.assertDoesNotThrow(() -> 
validate(Collections.singletonMap("url", url)));
+        }
+    }
+
+    @Test
+    void testMissingUrlRejected() {
+        Assertions.assertThrows(
+                OptionValidationException.class, () -> 
validate(Collections.emptyMap()));
+    }
+
+    @Test
+    void testEmptyUrlRejected() {
+        assertInvalidUrl("");
+    }
+
+    @Test
+    void testWhitespaceOnlyUrlRejected() {
+        assertInvalidUrl(" ");
+        assertInvalidUrl("\t\r\n");
+    }
+
+    private void assertInvalidUrl(String url) {
+        Assertions.assertThrows(
+                OptionValidationException.class,
+                () -> validate(Collections.singletonMap("url", url)));
+    }
+
+    private void validate(Map<String, Object> config) {
+        ReadonlyConfig readonlyConfig = ReadonlyConfig.fromMap(config);
+        ConfigValidator.validateUnknownKeys(readonlyConfig, optionRule, 
"Web3j");
+        ConfigValidator.of(readonlyConfig).validate(optionRule);
+    }
+}

Reply via email to