From 3333fadfe2b0b05b8a12a2b1685852fbb1c6376d Mon Sep 17 00:00:00 2001 From: Yohanes Date: Sat, 5 Sep 2026 18:14:20 +0800 Subject: [PATCH 1/9] [Improve][Core] Add JSON config validation output --- docs/en/engines/zeta/user-command.md | 7 +++++ docs/zh/engines/zeta/user-command.md | 7 +++++ .../core/starter/enums/OutputFormat.java | 23 ++++++++++++++ .../seatunnel/args/ClientCommandArgs.java | 30 +++++++++++++++++++ .../command/SeaTunnelConfValidateCommand.java | 25 ++++++++++++++-- .../seatunnel/args/ClientCommandArgsTest.java | 23 ++++++++++++++ 6 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/enums/OutputFormat.java diff --git a/docs/en/engines/zeta/user-command.md b/docs/en/engines/zeta/user-command.md index 6c238e965e07..d66020aedf21 100644 --- a/docs/en/engines/zeta/user-command.md +++ b/docs/en/engines/zeta/user-command.md @@ -29,6 +29,7 @@ Usage: seatunnel.sh [options] -d, --dry-run Validate or preview without running sinks. Supported modes: [static, connect, sample]. -m, --master, -e, --deploy-mode SeaTunnel job submit master, support [local, cluster] (default: cluster). --encrypt Encrypt the config file. When both --decrypt and --encrypt are specified, only --encrypt will take effect (default: false). + --format Validation output format. Supported values: [text, json] (default: text). --get_running_job_metrics Get metrics for running jobs (default: false). -h, --help Show the usage message. -j, --job-id Get the job status by JobId. @@ -70,6 +71,12 @@ sh bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --d The `--dry-run static` (or `--check`) option validates the configuration file **without submitting a job** (for example HOCON/YAML syntax, plugin loadability, DAG topology, missing required options, and unknown connector keys). It does not run the full data pipeline. Plugin loading may read local JARs, so this is offline validation of the configuration file, not a strict zero-I/O sandbox. +For machine-readable validation, add `--format json` to `--check`, `--dry-run static`, or `--dry-run connect`. The JSON document is written to standard output on both success and validation failure; a failed validation still exits with a non-zero status. + +```shell +sh bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --check --format json +``` + ```shell sh bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --dry-run connect ``` diff --git a/docs/zh/engines/zeta/user-command.md b/docs/zh/engines/zeta/user-command.md index 6c4f271f59cc..5cad40ff4213 100644 --- a/docs/zh/engines/zeta/user-command.md +++ b/docs/zh/engines/zeta/user-command.md @@ -40,6 +40,7 @@ Usage: seatunnel.sh [options] and --encrypt are specified, only --encrypt will take effect (default: false) + --format 校验输出格式。支持:[text, json](默认:text) --get_running_job_metrics Gets metrics for running jobs (default: false) -h, --help Show the usage message @@ -86,6 +87,12 @@ bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --dry- 使用 `--dry-run static`(或者 `--check`)参数可以在**不提交作业**的前提下静态校验配置文件(包括 HOCON/YAML 语法、插件可加载性、DAG 拓扑、必填项与未知配置键等)。它不会执行完整的数据管道。插件加载可能读取本地 JAR,因此这是配置文件的离线校验,不是严格的零 I/O 沙箱。 +需要机器可读的校验结果时,可在 `--check`、`--dry-run static` 或 `--dry-run connect` 后添加 `--format json`。无论校验成功还是失败,JSON 文档都会写入标准输出;校验失败仍会以非零状态码退出。 + +```shell +bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --check --format json +``` + ```shell bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --dry-run connect ``` diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/enums/OutputFormat.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/enums/OutputFormat.java new file mode 100644 index 000000000000..5ad3f22ca660 --- /dev/null +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/enums/OutputFormat.java @@ -0,0 +1,23 @@ +/* + * 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.core.starter.enums; + +public enum OutputFormat { + TEXT, + JSON +} diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java index e0625c4877f1..3b5cd7ac5052 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java @@ -25,6 +25,7 @@ import org.apache.seatunnel.core.starter.command.ConfEncryptCommand; import org.apache.seatunnel.core.starter.enums.DryRun; import org.apache.seatunnel.core.starter.enums.MasterType; +import org.apache.seatunnel.core.starter.enums.OutputFormat; import org.apache.seatunnel.core.starter.seatunnel.command.ClientExecuteCommand; import org.apache.seatunnel.core.starter.seatunnel.command.SeaTunnelConfValidateCommand; import org.apache.seatunnel.engine.common.config.DryRunSampleConfig; @@ -51,6 +52,12 @@ public class ClientCommandArgs extends AbstractCommandArgs { converter = DryRunConverter.class) protected DryRun dryRun = null; + @Parameter( + names = {"--format"}, + description = "Validation output format. Supported values: [text, json].", + converter = OutputFormatConverter.class) + private OutputFormat outputFormat = OutputFormat.TEXT; + @Parameter( names = {"--sample-limit"}, description = @@ -249,6 +256,24 @@ public DryRun convert(String value) { } } + public static class OutputFormatConverter implements IStringConverter { + @Override + public OutputFormat convert(String value) { + if (value == null || value.trim().isEmpty()) { + throw new IllegalArgumentException("Output format must not be empty."); + } + try { + return OutputFormat.valueOf(value.trim().toUpperCase()); + } catch (IllegalArgumentException e) { + throw new IllegalArgumentException( + "Unsupported output format '" + + value + + "'. Currently only [text, json] are supported.", + e); + } + } + } + /** Returns the configured sample limit, or the default limit when it was not specified. */ public int getSampleLimit() { return sampleLimit == null ? DryRunSampleConfig.DEFAULT_LIMIT : sampleLimit; @@ -257,6 +282,11 @@ public int getSampleLimit() { /** Validates options that depend on other command-line arguments. */ public void validateCommandOptions() { validateSampleOptions(); + if (outputFormat == OutputFormat.JSON + && (!checkConfig && dryRun == null || dryRun == DryRun.SAMPLE)) { + throw new ParameterException( + "--format json requires --check, --dry-run static, or --dry-run connect."); + } if (dryRun == DryRun.SAMPLE) { validateSampleMode(); } diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java index a1b77575e13f..e8b69f680f50 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java @@ -35,6 +35,7 @@ import org.apache.seatunnel.common.utils.DryRunConnectFailureMessageSanitizer; import org.apache.seatunnel.core.starter.command.Command; import org.apache.seatunnel.core.starter.enums.DryRun; +import org.apache.seatunnel.core.starter.enums.OutputFormat; import org.apache.seatunnel.core.starter.exception.ConfigCheckException; import org.apache.seatunnel.core.starter.seatunnel.args.ClientCommandArgs; import org.apache.seatunnel.core.starter.utils.ConfigBuilder; @@ -101,9 +102,8 @@ public SeaTunnelConfValidateCommand(ClientCommandArgs clientCommandArgs) { @Override public void execute() throws ConfigCheckException { - Path configPath = FileUtils.getConfigPath(clientCommandArgs); - try { + Path configPath = FileUtils.getConfigPath(clientCommandArgs); Config config = ConfigBuilder.of(configPath, clientCommandArgs.getVariables()); if (config.hasPath("env")) { @@ -183,6 +183,8 @@ public void execute() throws ConfigCheckException { .validate(); } + printJsonResultIfRequested(ConfigValidationResult.success(validationPhase())); + } catch (Exception e) { String validationMode = clientCommandArgs.getDryRun() == DryRun.CONNECT @@ -191,12 +193,31 @@ public void execute() throws ConfigCheckException { String message = e.getMessage(); if (clientCommandArgs.getDryRun() == DryRun.CONNECT) { message = DryRunConnectFailureMessageSanitizer.sanitize(message); + printJsonResultIfRequested( + ConfigValidationResult.failure( + validationPhase(), + toValidationError( + message == null ? "Validation failed" : message))); throw new ConfigCheckException(validationMode + " failed: " + message); } + String sanitizedMessage = DryRunConnectFailureMessageSanitizer.sanitize(message); + printJsonResultIfRequested( + ConfigValidationResult.failure( + validationPhase(), + toValidationError( + sanitizedMessage == null + ? "Validation failed" + : sanitizedMessage))); throw new ConfigCheckException(validationMode + " failed: " + message, e); } } + private void printJsonResultIfRequested(ConfigValidationResult result) { + if (clientCommandArgs.getOutputFormat() == OutputFormat.JSON) { + System.out.println(result.toJson()); + } + } + /** * Validate the configuration and return a reusable result for non-CLI integrations. * diff --git a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgsTest.java b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgsTest.java index 2d1bb9d9daab..3e9dd7c79a85 100644 --- a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgsTest.java +++ b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgsTest.java @@ -80,6 +80,29 @@ public void testDryRunParam() { Assertions.assertEquals(DryRun.STATIC, clientCommandArgs.getDryRun()); } + @Test + public void testJsonFormatRequiresValidationCommand() { + ClientCommandArgs args = + CommandLineUtils.parse( + new String[] {"-c", "app.conf", "--format", "json"}, + new ClientCommandArgs(), + "seatunnel-client", + true); + Assertions.assertThrows(com.beust.jcommander.ParameterException.class, args::buildCommand); + } + + @Test + public void testJsonFormatIsAcceptedForCheck() { + ClientCommandArgs args = + CommandLineUtils.parse( + new String[] {"-c", "app.conf", "--check", "--format", "json"}, + new ClientCommandArgs(), + "seatunnel-client", + true); + Assertions.assertEquals( + org.apache.seatunnel.core.starter.enums.OutputFormat.JSON, args.getOutputFormat()); + } + @Test public void testConnectDryRunParam() { String[] args = {"-c", "app.conf", "--dry-run", "connect"}; From 290c31f30fbf50e8f289697fc33c817b8b8b76f7 Mon Sep 17 00:00:00 2001 From: Yohanes Date: Sat, 5 Sep 2026 18:27:46 +0800 Subject: [PATCH 2/9] [Improve][Core] Cover JSON validation output --- .../SeaTunnelConfValidateCommandTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java index d44673bf1ad2..70eda73e7621 100644 --- a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java +++ b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java @@ -40,6 +40,8 @@ import java.util.Collections; import java.util.List; +import static com.github.stefanbirkner.systemlambda.SystemLambda.tapSystemOutNormalized; + public class SeaTunnelConfValidateCommandTest { @Test @@ -62,6 +64,45 @@ public void testValidationResultForValidConfig() { Assertions.assertTrue(result.getErrors().isEmpty()); } + @Test + public void testJsonOutputForSuccessfulValidation() throws Exception { + SeaTunnelConfValidateCommand command = + new SeaTunnelConfValidateCommand(buildJsonArgs("config/valid_static_dryrun.json")); + + String output = tapSystemOutNormalized(command::execute); + + Assertions.assertTrue(output.contains("\"valid\":true"), output); + Assertions.assertTrue(output.contains("\"phase\":\"static\""), output); + Assertions.assertTrue(output.contains("\"errors\":[]"), output); + } + + @Test + public void testJsonOutputForFailedValidationRetainsFailure() throws Exception { + SeaTunnelConfValidateCommand command = + new SeaTunnelConfValidateCommand( + buildJsonArgs("config/invalid_dryrun_missing_required.json")); + + String output = + tapSystemOutNormalized( + () -> + Assertions.assertThrows( + ConfigCheckException.class, command::execute)); + + Assertions.assertTrue(output.contains("\"valid\":false"), output); + Assertions.assertTrue(output.contains("\"phase\":\"static\""), output); + Assertions.assertTrue(output.contains("\"errors\":[{"), output); + } + + @Test + public void testDefaultOutputDoesNotEmitJson() throws Exception { + SeaTunnelConfValidateCommand command = + new SeaTunnelConfValidateCommand(buildArgs("config/valid_static_dryrun.json")); + + String output = tapSystemOutNormalized(command::execute); + + Assertions.assertFalse(output.contains("\"schemaVersion\""), output); + } + @Test public void testValidationResultClassifiesMissingPluginAsOptionError() throws Exception { Path configFile = Files.createTempFile("seatunnel-validation-result", ".conf"); @@ -610,6 +651,13 @@ private ClientCommandArgs buildArgsFromPath(String configPath) { return CommandLineUtils.parse(args, new ClientCommandArgs(), "seatunnel.sh", true); } + private ClientCommandArgs buildJsonArgs(String configFile) { + String[] args = { + "-c", resolveConfigPath(configFile), "--dry-run", "static", "--format", "json" + }; + return CommandLineUtils.parse(args, new ClientCommandArgs(), "seatunnel.sh", true); + } + private ClientCommandArgs buildConnectArgs(String configFile) { return buildConnectArgsFromPath(resolveConfigPath(configFile)); } From 0fec6dd3585684404a83b262b998d02ebdd8ee0f Mon Sep 17 00:00:00 2001 From: Yohanes Date: Sun, 6 Sep 2026 10:35:48 +0800 Subject: [PATCH 3/9] fix(core): sanitize static validation failures --- .../command/SeaTunnelConfValidateCommand.java | 2 +- .../SeaTunnelConfValidateCommandTest.java | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java index e8b69f680f50..8f745e656e2d 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java @@ -208,7 +208,7 @@ public void execute() throws ConfigCheckException { sanitizedMessage == null ? "Validation failed" : sanitizedMessage))); - throw new ConfigCheckException(validationMode + " failed: " + message, e); + throw new ConfigCheckException(validationMode + " failed: " + sanitizedMessage, e); } } diff --git a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java index 70eda73e7621..2a1903e3198b 100644 --- a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java +++ b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java @@ -93,6 +93,33 @@ public void testJsonOutputForFailedValidationRetainsFailure() throws Exception { Assertions.assertTrue(output.contains("\"errors\":[{"), output); } + @Test + public void testJsonStaticFailureSanitizesThrownException() throws Exception { + Path configFile = Files.createTempFile("seatunnel-static-sensitive-failure", ".json"); + Files.write( + configFile, + ("{\n" + + " \"env\": {\"parallelism\": 1, \"job.mode\": \"BATCH\"},\n" + + " \"source\": [{\"plugin_name\": " + + "\"jdbc:mysql://alice:secret-password@db.example.com:3306/orders\", " + + "\"plugin_output\": \"fake\"}],\n" + + " \"sink\": [{\"plugin_name\": \"Console\", " + + "\"plugin_input\": \"fake\"}]\n" + + "}") + .getBytes(StandardCharsets.UTF_8)); + configFile.toFile().deleteOnExit(); + + SeaTunnelConfValidateCommand command = + new SeaTunnelConfValidateCommand(buildJsonArgsFromPath(configFile.toString())); + ConfigCheckException exception = + Assertions.assertThrows(ConfigCheckException.class, command::execute); + + Assertions.assertFalse( + exception.getMessage().contains("secret-password"), exception.getMessage()); + Assertions.assertTrue( + exception.getMessage().contains("the configured JDBC URL"), exception.getMessage()); + } + @Test public void testDefaultOutputDoesNotEmitJson() throws Exception { SeaTunnelConfValidateCommand command = @@ -658,6 +685,11 @@ private ClientCommandArgs buildJsonArgs(String configFile) { return CommandLineUtils.parse(args, new ClientCommandArgs(), "seatunnel.sh", true); } + private ClientCommandArgs buildJsonArgsFromPath(String configPath) { + String[] args = {"-c", configPath, "--dry-run", "static", "--format", "json"}; + return CommandLineUtils.parse(args, new ClientCommandArgs(), "seatunnel.sh", true); + } + private ClientCommandArgs buildConnectArgs(String configFile) { return buildConnectArgsFromPath(resolveConfigPath(configFile)); } From 885428e53719a731ffdcf7cfcb2351b3615bd86c Mon Sep 17 00:00:00 2001 From: Yohanes Date: Mon, 7 Sep 2026 16:27:50 +0800 Subject: [PATCH 4/9] test(core): cover validation JSON escaping --- docs/en/engines/zeta/user-command.md | 2 ++ docs/zh/engines/zeta/user-command.md | 2 ++ .../validation/ConfigValidationResultTest.java | 16 ++++++++++++++++ .../seatunnel/args/ClientCommandArgs.java | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/docs/en/engines/zeta/user-command.md b/docs/en/engines/zeta/user-command.md index d66020aedf21..3e288390c987 100644 --- a/docs/en/engines/zeta/user-command.md +++ b/docs/en/engines/zeta/user-command.md @@ -73,6 +73,8 @@ The `--dry-run static` (or `--check`) option validates the configuration file ** For machine-readable validation, add `--format json` to `--check`, `--dry-run static`, or `--dry-run connect`. The JSON document is written to standard output on both success and validation failure; a failed validation still exits with a non-zero status. +The JSON contract contains `schemaVersion`, `valid`, `phase` (`static` or `connectivity`), and `errors`. Each entry in `errors` has `location`, `plugin`, `optionPath`, `ruleCategory`, and a sanitized `message`; unavailable fields are `null`. + ```shell sh bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --check --format json ``` diff --git a/docs/zh/engines/zeta/user-command.md b/docs/zh/engines/zeta/user-command.md index 5cad40ff4213..0392281da893 100644 --- a/docs/zh/engines/zeta/user-command.md +++ b/docs/zh/engines/zeta/user-command.md @@ -89,6 +89,8 @@ bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --dry- 需要机器可读的校验结果时,可在 `--check`、`--dry-run static` 或 `--dry-run connect` 后添加 `--format json`。无论校验成功还是失败,JSON 文档都会写入标准输出;校验失败仍会以非零状态码退出。 +JSON 契约包含 `schemaVersion`、`valid`、`phase`(`static` 或 `connectivity`)和 `errors`。`errors` 的每一项包含 `location`、`plugin`、`optionPath`、`ruleCategory` 与已脱敏的 `message`;无法提供的字段为 `null`。 + ```shell bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --check --format json ``` diff --git a/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/validation/ConfigValidationResultTest.java b/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/validation/ConfigValidationResultTest.java index 9d15fde2ad7e..c66225073b30 100644 --- a/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/validation/ConfigValidationResultTest.java +++ b/seatunnel-core/seatunnel-core-starter/src/test/java/org/apache/seatunnel/core/starter/validation/ConfigValidationResultTest.java @@ -63,4 +63,20 @@ void serializesFailureAndPreservesNullableFields() throws Exception { .at("/errors/0/ruleCategory") .asText()); } + + @Test + void escapesSpecialCharactersInErrorMessages() throws Exception { + String message = "Invalid value: \"quoted\"\nnext line\tcontrol"; + ConfigValidationResult result = + ConfigValidationResult.failure( + "static", + new ConfigValidationError(null, null, null, "validation", message)); + + Assertions.assertEquals( + message, + JsonUtils.readTree( + result.toJson().getBytes(java.nio.charset.StandardCharsets.UTF_8)) + .at("/errors/0/message") + .asText()); + } } diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java index 3b5cd7ac5052..d2b9fe7b8363 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/args/ClientCommandArgs.java @@ -283,7 +283,7 @@ public int getSampleLimit() { public void validateCommandOptions() { validateSampleOptions(); if (outputFormat == OutputFormat.JSON - && (!checkConfig && dryRun == null || dryRun == DryRun.SAMPLE)) { + && ((!checkConfig && dryRun == null) || dryRun == DryRun.SAMPLE)) { throw new ParameterException( "--format json requires --check, --dry-run static, or --dry-run connect."); } From a874fdef2883143985a33e4426d7fa9c6ae5a1dd Mon Sep 17 00:00:00 2001 From: Yohanes Date: Tue, 8 Sep 2026 10:58:33 +0800 Subject: [PATCH 5/9] fix(core): keep JSON output errors outside validation catch --- docs/en/engines/zeta/user-command.md | 2 +- docs/zh/engines/zeta/user-command.md | 2 +- .../seatunnel/command/SeaTunnelConfValidateCommand.java | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/en/engines/zeta/user-command.md b/docs/en/engines/zeta/user-command.md index 3e288390c987..23638e53eff5 100644 --- a/docs/en/engines/zeta/user-command.md +++ b/docs/en/engines/zeta/user-command.md @@ -71,7 +71,7 @@ sh bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --d The `--dry-run static` (or `--check`) option validates the configuration file **without submitting a job** (for example HOCON/YAML syntax, plugin loadability, DAG topology, missing required options, and unknown connector keys). It does not run the full data pipeline. Plugin loading may read local JARs, so this is offline validation of the configuration file, not a strict zero-I/O sandbox. -For machine-readable validation, add `--format json` to `--check`, `--dry-run static`, or `--dry-run connect`. The JSON document is written to standard output on both success and validation failure; a failed validation still exits with a non-zero status. +For machine-readable validation, add `--format json` to `--check`, `--dry-run static`, or `--dry-run connect`. The validation result is written to standard output on both success and validation failure; a failed validation still exits with a non-zero status. Existing diagnostic messages from the validation path may also be written to standard output, so callers should select the result line as the machine-readable record. The JSON contract contains `schemaVersion`, `valid`, `phase` (`static` or `connectivity`), and `errors`. Each entry in `errors` has `location`, `plugin`, `optionPath`, `ruleCategory`, and a sanitized `message`; unavailable fields are `null`. diff --git a/docs/zh/engines/zeta/user-command.md b/docs/zh/engines/zeta/user-command.md index 0392281da893..d78043a6e411 100644 --- a/docs/zh/engines/zeta/user-command.md +++ b/docs/zh/engines/zeta/user-command.md @@ -87,7 +87,7 @@ bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --dry- 使用 `--dry-run static`(或者 `--check`)参数可以在**不提交作业**的前提下静态校验配置文件(包括 HOCON/YAML 语法、插件可加载性、DAG 拓扑、必填项与未知配置键等)。它不会执行完整的数据管道。插件加载可能读取本地 JAR,因此这是配置文件的离线校验,不是严格的零 I/O 沙箱。 -需要机器可读的校验结果时,可在 `--check`、`--dry-run static` 或 `--dry-run connect` 后添加 `--format json`。无论校验成功还是失败,JSON 文档都会写入标准输出;校验失败仍会以非零状态码退出。 +需要机器可读的校验结果时,可在 `--check`、`--dry-run static` 或 `--dry-run connect` 后添加 `--format json`。无论校验成功还是失败,校验结果都会写入标准输出;校验失败仍会以非零状态码退出。校验路径中已有的诊断信息也可能写入标准输出,调用方应从输出中选取结果行作为机器可读记录。 JSON 契约包含 `schemaVersion`、`valid`、`phase`(`static` 或 `connectivity`)和 `errors`。`errors` 的每一项包含 `location`、`plugin`、`optionPath`、`ruleCategory` 与已脱敏的 `message`;无法提供的字段为 `null`。 diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java index 8f745e656e2d..d0b0d0fdce05 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java @@ -102,6 +102,7 @@ public SeaTunnelConfValidateCommand(ClientCommandArgs clientCommandArgs) { @Override public void execute() throws ConfigCheckException { + ConfigValidationResult successResult; try { Path configPath = FileUtils.getConfigPath(clientCommandArgs); Config config = ConfigBuilder.of(configPath, clientCommandArgs.getVariables()); @@ -183,7 +184,7 @@ public void execute() throws ConfigCheckException { .validate(); } - printJsonResultIfRequested(ConfigValidationResult.success(validationPhase())); + successResult = ConfigValidationResult.success(validationPhase()); } catch (Exception e) { String validationMode = @@ -210,6 +211,9 @@ public void execute() throws ConfigCheckException { : sanitizedMessage))); throw new ConfigCheckException(validationMode + " failed: " + sanitizedMessage, e); } + // Keep serialization outside the validation try/catch so an output failure + // cannot be reported as a configuration-validation failure. + printJsonResultIfRequested(successResult); } private void printJsonResultIfRequested(ConfigValidationResult result) { From ce93a3a4412c53216b63c0a450191bc21c64205f Mon Sep 17 00:00:00 2001 From: Yohanes Date: Mon, 16 Nov 2026 21:29:13 +0800 Subject: [PATCH 6/9] [Fix][Core] Separate validation JSON from CLI diagnostics --- config/log4j2_client.properties | 4 +- docs/en/engines/zeta/user-command.md | 2 +- docs/zh/engines/zeta/user-command.md | 2 +- .../src/main/bin/seatunnel.sh | 8 ++ .../starter/seatunnel/SeaTunnelClient.java | 14 +++- .../command/SeaTunnelConfValidateCommand.java | 74 ++++++++----------- .../SeaTunnelConfValidateCommandTest.java | 73 ++++++++++++++---- .../seatunnel/SeaTunnelConnectorTest.java | 59 +++++++++++++++ .../src/test/resources/json_validation.conf | 32 ++++++++ 9 files changed, 203 insertions(+), 65 deletions(-) create mode 100644 seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/resources/json_validation.conf diff --git a/config/log4j2_client.properties b/config/log4j2_client.properties index 0c751b150956..590914a9eb77 100644 --- a/config/log4j2_client.properties +++ b/config/log4j2_client.properties @@ -37,7 +37,7 @@ rootLogger.appenderRef.consoleStderr.ref = consoleStderrAppender appender.consoleStdout.name = consoleStdoutAppender appender.consoleStdout.type = CONSOLE -appender.consoleStdout.target = SYSTEM_OUT +appender.consoleStdout.target = ${sys:seatunnel.console.target:-SYSTEM_OUT} appender.consoleStdout.layout.type = PatternLayout appender.consoleStdout.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%-30.30c{1.}] [%t] - %m%n appender.consoleStdout.filter.acceptLtWarn.type = ThresholdFilter @@ -78,4 +78,4 @@ appender.consoleStderr.filter.acceptGteWarn.onMismatch = DENY #appender.file.strategy.action.condition.nested_condition.lastModify.type = IfLastModified #appender.file.strategy.action.condition.nested_condition.lastModify.age = ${file_ttl} #appender.file.strategy.action.condition.nested_condition.fileCount.type = IfAccumulatedFileCount -#appender.file.strategy.action.condition.nested_condition.fileCount.exceeds = ${file_count} \ No newline at end of file +#appender.file.strategy.action.condition.nested_condition.fileCount.exceeds = ${file_count} diff --git a/docs/en/engines/zeta/user-command.md b/docs/en/engines/zeta/user-command.md index f31b35107b03..9292745ca8a0 100644 --- a/docs/en/engines/zeta/user-command.md +++ b/docs/en/engines/zeta/user-command.md @@ -82,7 +82,7 @@ sh bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --d The `--dry-run static` (or `--check`) option validates the configuration file **without submitting a job** (for example HOCON/YAML syntax, plugin loadability, DAG topology, missing required options, and unknown connector keys). It does not run the full data pipeline. Plugin loading may read local JARs, so this is offline validation of the configuration file, not a strict zero-I/O sandbox. -For machine-readable validation, add `--format json` to `--check`, `--dry-run static`, or `--dry-run connect`. The validation result is written to standard output on both success and validation failure; a failed validation still exits with a non-zero status. Existing diagnostic messages from the validation path may also be written to standard output, so callers should select the result line as the machine-readable record. +For machine-readable validation, add `--format json` to `--check`, `--dry-run static`, or `--dry-run connect`. The validation result is written as one JSON document to standard output on both success and validation failure; a failed validation exits with status 1. The supplied Bash launcher and client logging configuration send diagnostics to standard error in this mode. Other launchers must set `-Dseatunnel.console.target=SYSTEM_ERR` before starting the JVM; custom logging configurations must also keep diagnostics off standard output. The JSON contract contains `schemaVersion`, `valid`, `phase` (`static` or `connectivity`), and `errors`. Each entry in `errors` has `location`, `plugin`, `optionPath`, `ruleCategory`, and a sanitized `message`; unavailable fields are `null`. diff --git a/docs/zh/engines/zeta/user-command.md b/docs/zh/engines/zeta/user-command.md index 2c4021e45ff2..a81cbec9ba70 100644 --- a/docs/zh/engines/zeta/user-command.md +++ b/docs/zh/engines/zeta/user-command.md @@ -97,7 +97,7 @@ bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --dry- 使用 `--dry-run static`(或者 `--check`)参数可以在**不提交作业**的前提下静态校验配置文件(包括 HOCON/YAML 语法、插件可加载性、DAG 拓扑、必填项与未知配置键等)。它不会执行完整的数据管道。插件加载可能读取本地 JAR,因此这是配置文件的离线校验,不是严格的零 I/O 沙箱。 -需要机器可读的校验结果时,可在 `--check`、`--dry-run static` 或 `--dry-run connect` 后添加 `--format json`。无论校验成功还是失败,校验结果都会写入标准输出;校验失败仍会以非零状态码退出。校验路径中已有的诊断信息也可能写入标准输出,调用方应从输出中选取结果行作为机器可读记录。 +需要机器可读的校验结果时,可在 `--check`、`--dry-run static` 或 `--dry-run connect` 后添加 `--format json`。无论校验成功还是失败,标准输出都只写入一份 JSON 文档;校验失败以状态码 1 退出。随发行版提供的 Bash 启动脚本和客户端日志配置会在该模式下将诊断信息写入标准错误。其他启动入口需要在 JVM 启动前设置 `-Dseatunnel.console.target=SYSTEM_ERR`;自定义日志配置也必须避免向标准输出写入诊断信息。 JSON 契约包含 `schemaVersion`、`valid`、`phase`(`static` 或 `connectivity`)和 `errors`。`errors` 的每一项包含 `location`、`plugin`、`optionPath`、`ruleCategory` 与已脱敏的 `message`;无法提供的字段为 `null`。 diff --git a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh index a88704b57bcd..1553860655fa 100755 --- a/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh +++ b/seatunnel-core/seatunnel-starter/src/main/bin/seatunnel.sh @@ -79,6 +79,14 @@ JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.config=${HAZELCAST_CONFIG}" # JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=5000,suspend=n" # Log4j2 Config +# Keep validation diagnostics off the JSON protocol's stdout. Set the target before Log4j starts. +previous_arg="" +for arg in "${args[@]}"; do + if [[ ( "$previous_arg" == "--format" && "$arg" == [Jj][Ss][Oo][Nn] ) || "$arg" == --format=[Jj][Ss][Oo][Nn] ]]; then + JAVA_OPTS="${JAVA_OPTS} -Dseatunnel.console.target=SYSTEM_ERR" + fi + previous_arg="$arg" +done JAVA_OPTS="${JAVA_OPTS} -Dlog4j2.isThreadContextMapInheritable=true" if [ -e "${CONF_DIR}/log4j2_client.properties" ]; then JAVA_OPTS="${JAVA_OPTS} -Dhazelcast.logging.type=log4j2 -Dlog4j2.configurationFile=${CONF_DIR}/log4j2_client.properties" diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelClient.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelClient.java index 0213d49e2c62..17137759dff7 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelClient.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelClient.java @@ -21,8 +21,11 @@ import org.apache.seatunnel.common.constants.EngineType; import org.apache.seatunnel.core.starter.SeaTunnel; +import org.apache.seatunnel.core.starter.command.Command; +import org.apache.seatunnel.core.starter.enums.OutputFormat; import org.apache.seatunnel.core.starter.exception.CommandException; import org.apache.seatunnel.core.starter.seatunnel.args.ClientCommandArgs; +import org.apache.seatunnel.core.starter.seatunnel.command.SeaTunnelConfValidateCommand; import org.apache.seatunnel.core.starter.utils.CommandLineUtils; import lombok.extern.slf4j.Slf4j; @@ -41,7 +44,16 @@ public static void main(String[] args) throws CommandException { ClientCommandArgs::validateCommandOptions, HELP_EXIT_CODE); try { - SeaTunnel.run(clientCommandArgs.buildCommand()); + Command command = clientCommandArgs.buildCommand(); + if (clientCommandArgs.getOutputFormat() == OutputFormat.JSON + && command instanceof SeaTunnelConfValidateCommand) { + int exitCode = ((SeaTunnelConfValidateCommand) command).executeForExitCode(); + if (exitCode != 0) { + System.exit(exitCode); + } + return; + } + SeaTunnel.run(command); } catch (Error e) { log.error("Exception StackTrace: {}", ExceptionUtils.getStackTrace(e)); System.exit(1); diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java index 7f456ef9ffdf..188fdaa4c43f 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java @@ -102,9 +102,27 @@ public SeaTunnelConfValidateCommand(ClientCommandArgs clientCommandArgs) { @Override public void execute() throws ConfigCheckException { - ConfigValidationResult successResult; + executeForExitCode(); + } + + /** + * Runs the CLI adapter and returns its exit status. JSON validation failures are represented by + * the result and status, not by an exception that the launcher would log as text. + */ + public int executeForExitCode() throws ConfigCheckException { + if (clientCommandArgs.getOutputFormat() == OutputFormat.JSON) { + ConfigValidationResult result = validateResult(); + System.out.println(result.toJson()); + return result.isValid() ? 0 : 1; + } + validateConfig(); + return 0; + } + + private void validateConfig() throws ConfigCheckException { + // Preserve the original path-resolution exception contract in default text mode. + Path configPath = FileUtils.getConfigPath(clientCommandArgs); try { - Path configPath = FileUtils.getConfigPath(clientCommandArgs); Config config = ConfigBuilder.of(configPath, clientCommandArgs.getVariables()); if (config.hasPath("env")) { @@ -184,41 +202,16 @@ public void execute() throws ConfigCheckException { .validate(); } - successResult = ConfigValidationResult.success(validationPhase()); - } catch (Exception e) { - String validationMode = - clientCommandArgs.getDryRun() == DryRun.CONNECT - ? "Connectivity check" - : "Static analysis"; - String message = e.getMessage(); + String message = safeMessage(e.getMessage()); if (clientCommandArgs.getDryRun() == DryRun.CONNECT) { - message = DryRunConnectFailureMessageSanitizer.sanitize(message); - printJsonResultIfRequested( - ConfigValidationResult.failure( - validationPhase(), - toValidationError( - message == null ? "Validation failed" : message))); - throw new ConfigCheckException(validationMode + " failed: " + message); + throw new ConfigCheckException(validationMode() + " failed: " + message); } - String sanitizedMessage = DryRunConnectFailureMessageSanitizer.sanitize(message); - printJsonResultIfRequested( - ConfigValidationResult.failure( - validationPhase(), - toValidationError( - sanitizedMessage == null - ? "Validation failed" - : sanitizedMessage))); if (clientCommandArgs.getOutputFormat() == OutputFormat.JSON) { - // The CLI logs the full exception chain; do not retain an unsanitized cause in - // the machine-readable mode after emitting the credential-safe result. - throw new ConfigCheckException(validationMode + " failed: " + sanitizedMessage); + throw new ConfigCheckException(validationMode() + " failed: " + message); } - throw new ConfigCheckException(validationMode + " failed: " + sanitizedMessage, e); + throw new ConfigCheckException(validationMode() + " failed: " + message, e); } - // Keep serialization outside the validation try/catch so an output failure - // cannot be reported as a configuration-validation failure. - printJsonResultIfRequested(successResult); } /** @@ -228,9 +221,9 @@ public void execute() throws ConfigCheckException { */ public ConfigValidationResult validateResult() { try { - execute(); + validateConfig(); return ConfigValidationResult.success(validationPhase()); - } catch (ConfigCheckException e) { + } catch (Exception e) { String message = e.getMessage(); String prefix = validationMode() + " failed: "; if (message != null && message.startsWith(prefix)) { @@ -238,21 +231,14 @@ public ConfigValidationResult validateResult() { } // The result is intended for programmatic consumers, so never expose credentials // even when the underlying validation phase is static. - message = DryRunConnectFailureMessageSanitizer.sanitize(message); return ConfigValidationResult.failure( - validationPhase(), - toValidationError(message == null ? "Validation failed" : message)); + validationPhase(), toValidationError(safeMessage(message))); } } - /** - * Emits one credential-safe result for the JSON CLI protocol. Text mode retains its existing - * diagnostic output and does not write a machine-readable result to standard output. - */ - private void printJsonResultIfRequested(ConfigValidationResult result) { - if (clientCommandArgs.getOutputFormat() == OutputFormat.JSON) { - System.out.println(result.toJson()); - } + private static String safeMessage(String message) { + return DryRunConnectFailureMessageSanitizer.sanitize( + message == null ? "Validation failed" : message); } private String validationPhase() { diff --git a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java index 2c3d2c620f7c..df7e66d79c45 100644 --- a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java +++ b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java @@ -19,18 +19,21 @@ import org.apache.seatunnel.shade.com.typesafe.config.Config; import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory; -import org.apache.seatunnel.shade.org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.seatunnel.common.constants.PluginType; import org.apache.seatunnel.common.utils.JsonUtils; import org.apache.seatunnel.core.starter.exception.ConfigCheckException; +import org.apache.seatunnel.core.starter.seatunnel.SeaTunnelClient; import org.apache.seatunnel.core.starter.seatunnel.args.ClientCommandArgs; import org.apache.seatunnel.core.starter.utils.CommandLineUtils; import org.apache.seatunnel.core.starter.utils.ConfigBuilder; +import org.apache.seatunnel.core.starter.utils.FileUtils; import org.apache.seatunnel.core.starter.validation.ConfigValidationResult; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; import java.io.PrintWriter; import java.io.StringWriter; @@ -42,6 +45,7 @@ import java.util.Collections; import java.util.List; +import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit; import static com.github.stefanbirkner.systemlambda.SystemLambda.tapSystemOutNormalized; public class SeaTunnelConfValidateCommandTest { @@ -86,9 +90,7 @@ public void testJsonOutputForFailedValidationRetainsFailure() throws Exception { String output = tapSystemOutNormalized( - () -> - Assertions.assertThrows( - ConfigCheckException.class, command::execute)); + () -> Assertions.assertEquals(1, command.executeForExitCode())); Assertions.assertTrue(output.contains("\"valid\":false"), output); Assertions.assertTrue(output.contains("\"phase\":\"static\""), output); @@ -96,7 +98,7 @@ public void testJsonOutputForFailedValidationRetainsFailure() throws Exception { } @Test - public void testJsonStaticFailureSanitizesThrownException() throws Exception { + public void testJsonStaticFailureSanitizesResultWithoutThrowing() throws Exception { Path configFile = Files.createTempFile("seatunnel-static-sensitive-failure", ".json"); Files.write( configFile, @@ -115,17 +117,7 @@ public void testJsonStaticFailureSanitizesThrownException() throws Exception { new SeaTunnelConfValidateCommand(buildJsonArgsFromPath(configFile.toString())); String output = tapSystemOutNormalized( - () -> { - ConfigCheckException exception = - Assertions.assertThrows( - ConfigCheckException.class, command::execute); - String stackTrace = ExceptionUtils.getStackTrace(exception); - Assertions.assertFalse( - stackTrace.contains("secret-password"), stackTrace); - Assertions.assertTrue( - exception.getMessage().contains("the configured JDBC URL"), - exception.getMessage()); - }); + () -> Assertions.assertEquals(1, command.executeForExitCode())); Assertions.assertFalse(output.contains("secret-password"), output); Assertions.assertFalse( @@ -150,6 +142,55 @@ public void testDefaultOutputDoesNotEmitJson() throws Exception { Assertions.assertFalse(output.contains("\"schemaVersion\""), output); } + @Test + public void testJsonLauncherFailureExitsWithoutTextExceptionLogging() throws Exception { + String[] args = { + "-c", + resolveConfigPath("config/invalid_dryrun_missing_required.json"), + "--check", + "--format", + "json" + }; + String output = + tapSystemOutNormalized( + () -> + Assertions.assertEquals( + 1, catchSystemExit(() -> SeaTunnelClient.main(args)))); + Assertions.assertEquals(1, output.trim().split("\\R").length, output); + Assertions.assertFalse( + JsonUtils.readTree(output.getBytes(StandardCharsets.UTF_8)) + .get("valid") + .asBoolean()); + Assertions.assertFalse(output.contains("Config Error"), output); + } + + @Test + public void testJsonProgrammaticValidationDoesNotEmitOutput() throws Exception { + SeaTunnelConfValidateCommand command = + new SeaTunnelConfValidateCommand( + buildJsonArgs("config/invalid_dryrun_missing_required.json")); + String output = + tapSystemOutNormalized( + () -> Assertions.assertFalse(command.validateResult().isValid())); + Assertions.assertEquals("", output); + } + + @Test + public void testNullMessageAndPathResolutionPreserveTextContract() throws Exception { + ClientCommandArgs textArgs = buildArgs("config/valid_static_dryrun.json"); + IllegalArgumentException failure = new IllegalArgumentException(); + try (MockedStatic files = Mockito.mockStatic(FileUtils.class)) { + files.when(() -> FileUtils.getConfigPath(textArgs)).thenThrow(failure); + SeaTunnelConfValidateCommand textCommand = new SeaTunnelConfValidateCommand(textArgs); + Assertions.assertSame( + failure, + Assertions.assertThrows(IllegalArgumentException.class, textCommand::execute)); + ConfigValidationResult result = textCommand.validateResult(); + Assertions.assertFalse(result.isValid()); + Assertions.assertEquals("Validation failed", result.getErrors().get(0).getMessage()); + } + } + @Test public void testValidationResultClassifiesMissingPluginAsOptionError() throws Exception { Path configFile = Files.createTempFile("seatunnel-validation-result", ".conf"); diff --git a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java index da0dc9f7c2fa..01788ca39997 100644 --- a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java +++ b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java @@ -23,6 +23,7 @@ import org.apache.seatunnel.api.configuration.util.OptionRule; import org.apache.seatunnel.api.table.factory.Factory; import org.apache.seatunnel.common.constants.PluginType; +import org.apache.seatunnel.common.utils.JsonUtils; import org.apache.seatunnel.connectors.seatunnel.paimon.sink.PaimonSinkFactory; import org.apache.seatunnel.connectors.seatunnel.paimon.source.PaimonSourceFactory; import org.apache.seatunnel.e2e.common.TestResource; @@ -38,10 +39,12 @@ import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; import org.testcontainers.containers.Container; +import org.testcontainers.utility.MountableFile; import lombok.extern.slf4j.Slf4j; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -125,6 +128,62 @@ public void testExecCheck(TestContainer container) throws Exception { execResult7.getStdout(), new SQLTransformFactory()); } + @TestTemplate + public void testJsonValidationStdoutAndExitStatus(TestContainer container) throws Exception { + // Exercise the source launcher/logging config with only the fixture's connectors. + container.executeExtraCommands( + engine -> { + ContainerUtil.copyConnectorJarToContainer( + engine, + "/json_validation.conf", + "seatunnel-connectors-v2", + "connector", + "seatunnel", + "/tmp/seatunnel"); + engine.copyFileToContainer( + MountableFile.forClasspathResource("json_validation.conf"), + "/tmp/seatunnel/config/json_validation.conf"); + engine.copyFileToContainer( + MountableFile.forHostPath( + ContainerUtil.PROJECT_ROOT_PATH + + "/config/log4j2_client.properties"), + "/tmp/seatunnel/config/log4j2_client.properties"); + }); + Container.ExecResult valid = + container.executeBaseCommand( + new String[] { + "--config", + "/tmp/seatunnel/config/json_validation.conf", + "--check", + "--format", + "json" + }); + Assertions.assertEquals(0, valid.getExitCode(), valid.getStdout() + valid.getStderr()); + Assertions.assertEquals(1, valid.getStdout().trim().split("\\R").length, valid.getStdout()); + Assertions.assertTrue( + JsonUtils.readTree(valid.getStdout().getBytes(StandardCharsets.UTF_8)) + .get("valid") + .asBoolean()); + + Container.ExecResult invalid = + container.executeBaseCommand( + new String[] { + "--config", + "/tmp/seatunnel/config/nonexistent-validation.conf", + "--check", + "--format", + "json" + }); + Assertions.assertEquals(1, invalid.getExitCode(), invalid.getStderr()); + Assertions.assertEquals( + 1, invalid.getStdout().trim().split("\\R").length, invalid.getStdout()); + Assertions.assertFalse( + JsonUtils.readTree(invalid.getStdout().getBytes(StandardCharsets.UTF_8)) + .get("valid") + .asBoolean()); + Assertions.assertFalse(invalid.getStderr().contains("Config Error"), invalid.getStderr()); + } + private void checkStdOutForOptionRule(String stdout) { Matcher matcher1 = PATTERN1.matcher(stdout.trim()); String paimonSourceContent = StringUtils.EMPTY; diff --git a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/resources/json_validation.conf b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/resources/json_validation.conf new file mode 100644 index 000000000000..83fb3f1eff90 --- /dev/null +++ b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/resources/json_validation.conf @@ -0,0 +1,32 @@ +# 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. + +env { + job.mode = BATCH + parallelism = 1 +} +source { + FakeSource { + row.num = 1 + schema = { + fields = { + id = "int" + } + } + } +} +sink { + Console {} +} From 90fd7b7eb2ccaf683cb6e9d38487351e61babf90 Mon Sep 17 00:00:00 2001 From: Yohanes Date: Tue, 17 Nov 2026 11:43:20 +0800 Subject: [PATCH 7/9] [Fix][Core] Keep static validation exception chains credential-safe --- docs/en/engines/zeta/user-command.md | 2 + docs/zh/engines/zeta/user-command.md | 2 + .../command/SeaTunnelConfValidateCommand.java | 10 ++--- .../SeaTunnelConfValidateCommandTest.java | 45 +++++++++++++++++++ .../seatunnel/SeaTunnelConnectorTest.java | 21 +++++++++ 5 files changed, 73 insertions(+), 7 deletions(-) diff --git a/docs/en/engines/zeta/user-command.md b/docs/en/engines/zeta/user-command.md index 9292745ca8a0..57e701471a06 100644 --- a/docs/en/engines/zeta/user-command.md +++ b/docs/en/engines/zeta/user-command.md @@ -84,6 +84,8 @@ The `--dry-run static` (or `--check`) option validates the configuration file ** For machine-readable validation, add `--format json` to `--check`, `--dry-run static`, or `--dry-run connect`. The validation result is written as one JSON document to standard output on both success and validation failure; a failed validation exits with status 1. The supplied Bash launcher and client logging configuration send diagnostics to standard error in this mode. Other launchers must set `-Dseatunnel.console.target=SYSTEM_ERR` before starting the JVM; custom logging configurations must also keep diagnostics off standard output. +The JSON stdout contract is covered by the Bash launcher integration test; native Windows launchers are not covered by that test. In both text and JSON modes, validation failures use sanitized messages and omit the original exception cause to avoid exposing credentials through stack traces. A missing exception message is reported as `Validation failed`. + The JSON contract contains `schemaVersion`, `valid`, `phase` (`static` or `connectivity`), and `errors`. Each entry in `errors` has `location`, `plugin`, `optionPath`, `ruleCategory`, and a sanitized `message`; unavailable fields are `null`. ```shell diff --git a/docs/zh/engines/zeta/user-command.md b/docs/zh/engines/zeta/user-command.md index a81cbec9ba70..c83500a10a9e 100644 --- a/docs/zh/engines/zeta/user-command.md +++ b/docs/zh/engines/zeta/user-command.md @@ -99,6 +99,8 @@ bin/seatunnel.sh --config $SEATUNNEL_HOME/config/v2.batch.config.template --dry- 需要机器可读的校验结果时,可在 `--check`、`--dry-run static` 或 `--dry-run connect` 后添加 `--format json`。无论校验成功还是失败,标准输出都只写入一份 JSON 文档;校验失败以状态码 1 退出。随发行版提供的 Bash 启动脚本和客户端日志配置会在该模式下将诊断信息写入标准错误。其他启动入口需要在 JVM 启动前设置 `-Dseatunnel.console.target=SYSTEM_ERR`;自定义日志配置也必须避免向标准输出写入诊断信息。 +JSON 标准输出契约由 Bash 启动脚本集成测试覆盖;该测试不覆盖原生 Windows 启动入口。文本与 JSON 模式的校验失败均使用脱敏后的消息,并省略原始异常原因,避免通过堆栈泄露凭据。异常没有消息时,使用 `Validation failed`。 + JSON 契约包含 `schemaVersion`、`valid`、`phase`(`static` 或 `connectivity`)和 `errors`。`errors` 的每一项包含 `location`、`plugin`、`optionPath`、`ruleCategory` 与已脱敏的 `message`;无法提供的字段为 `null`。 ```shell diff --git a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java index 188fdaa4c43f..4788d1139a65 100644 --- a/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java +++ b/seatunnel-core/seatunnel-starter/src/main/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommand.java @@ -204,13 +204,9 @@ private void validateConfig() throws ConfigCheckException { } catch (Exception e) { String message = safeMessage(e.getMessage()); - if (clientCommandArgs.getDryRun() == DryRun.CONNECT) { - throw new ConfigCheckException(validationMode() + " failed: " + message); - } - if (clientCommandArgs.getOutputFormat() == OutputFormat.JSON) { - throw new ConfigCheckException(validationMode() + " failed: " + message); - } - throw new ConfigCheckException(validationMode() + " failed: " + message, e); + // The launcher logs the complete exception chain in text mode too. + // Do not reattach a cause that can contain the unredacted configuration. + throw new ConfigCheckException(validationMode() + " failed: " + message); } } diff --git a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java index df7e66d79c45..ca909c3dadda 100644 --- a/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java +++ b/seatunnel-core/seatunnel-starter/src/test/java/org/apache/seatunnel/core/starter/seatunnel/command/SeaTunnelConfValidateCommandTest.java @@ -191,6 +191,51 @@ public void testNullMessageAndPathResolutionPreserveTextContract() throws Except } } + @Test + public void testStaticTextFailureDoesNotExposeRawCause() { + ClientCommandArgs args = buildArgs("config/valid_static_dryrun.json"); + Path configPath = FileUtils.getConfigPath(args); + IllegalArgumentException failure = + new IllegalArgumentException( + "password=fixture-password token=fixture-token", + new IllegalStateException("nested credential=fixture-credential")); + try (MockedStatic configs = Mockito.mockStatic(ConfigBuilder.class)) { + configs.when(() -> ConfigBuilder.of(configPath, args.getVariables())) + .thenThrow(failure); + SeaTunnelConfValidateCommand command = new SeaTunnelConfValidateCommand(args); + + ConfigCheckException exception = + Assertions.assertThrows(ConfigCheckException.class, command::execute); + + Assertions.assertTrue(exception.getMessage().startsWith("Static analysis failed: ")); + Assertions.assertTrue(exception.getMessage().contains("password=***")); + Assertions.assertTrue(exception.getMessage().contains("token=***")); + StringWriter stackTrace = new StringWriter(); + exception.printStackTrace(new PrintWriter(stackTrace)); + Assertions.assertFalse(stackTrace.toString().contains("fixture-password")); + Assertions.assertFalse(stackTrace.toString().contains("fixture-token")); + Assertions.assertFalse(stackTrace.toString().contains("fixture-credential")); + Assertions.assertNull(exception.getCause()); + } + } + + @Test + public void testStaticTextNullMessageUsesFallback() { + ClientCommandArgs args = buildArgs("config/valid_static_dryrun.json"); + Path configPath = FileUtils.getConfigPath(args); + try (MockedStatic configs = Mockito.mockStatic(ConfigBuilder.class)) { + configs.when(() -> ConfigBuilder.of(configPath, args.getVariables())) + .thenThrow(new IllegalArgumentException()); + SeaTunnelConfValidateCommand command = new SeaTunnelConfValidateCommand(args); + + ConfigCheckException exception = + Assertions.assertThrows(ConfigCheckException.class, command::execute); + + Assertions.assertEquals( + "Static analysis failed: Validation failed", exception.getMessage()); + } + } + @Test public void testValidationResultClassifiesMissingPluginAsOptionError() throws Exception { Path configFile = Files.createTempFile("seatunnel-validation-result", ".conf"); diff --git a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java index 01788ca39997..38b79beba830 100644 --- a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java +++ b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java @@ -39,6 +39,7 @@ import org.junit.jupiter.api.condition.DisabledOnOs; import org.junit.jupiter.api.condition.OS; import org.testcontainers.containers.Container; +import org.testcontainers.images.builder.Transferable; import org.testcontainers.utility.MountableFile; import lombok.extern.slf4j.Slf4j; @@ -143,6 +144,15 @@ public void testJsonValidationStdoutAndExitStatus(TestContainer container) throw engine.copyFileToContainer( MountableFile.forClasspathResource("json_validation.conf"), "/tmp/seatunnel/config/json_validation.conf"); + engine.copyFileToContainer( + Transferable.of( + ("env {\n" + + " job.mode = \"jdbc:mysql://alice:fixture-password@db.invalid:3306/orders\"\n" + + "}\n" + + "source { FakeSource {} }\n" + + "sink { Console {} }") + .getBytes(StandardCharsets.UTF_8)), + "/tmp/seatunnel/config/sensitive-validation.conf"); engine.copyFileToContainer( MountableFile.forHostPath( ContainerUtil.PROJECT_ROOT_PATH @@ -182,6 +192,17 @@ public void testJsonValidationStdoutAndExitStatus(TestContainer container) throw .get("valid") .asBoolean()); Assertions.assertFalse(invalid.getStderr().contains("Config Error"), invalid.getStderr()); + + Container.ExecResult invalidText = + container.executeBaseCommand( + new String[] { + "--config", "/tmp/seatunnel/config/sensitive-validation.conf", "--check" + }); + String diagnostics = invalidText.getStdout() + invalidText.getStderr(); + Assertions.assertEquals(1, invalidText.getExitCode(), diagnostics); + Assertions.assertTrue(diagnostics.contains("Static analysis failed:"), diagnostics); + Assertions.assertTrue(diagnostics.contains("the configured JDBC URL"), diagnostics); + Assertions.assertFalse(diagnostics.contains("fixture-password"), diagnostics); } private void checkStdOutForOptionRule(String stdout) { From 841c8d50c14348007d68d0d4c2764e0591790422 Mon Sep 17 00:00:00 2001 From: Yohanes Date: Wed, 18 Nov 2026 10:01:28 +0800 Subject: [PATCH 8/9] [Test][Core] Reject trailing output in JSON validation checks --- .../starter/seatunnel/SeaTunnelConnectorTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java index 38b79beba830..b70e823719a8 100644 --- a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java +++ b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java @@ -17,13 +17,14 @@ package org.apache.seatunnel.core.starter.seatunnel; +import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.DeserializationFeature; +import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper; import org.apache.seatunnel.shade.org.apache.commons.lang3.StringUtils; import org.apache.seatunnel.api.configuration.Option; import org.apache.seatunnel.api.configuration.util.OptionRule; import org.apache.seatunnel.api.table.factory.Factory; import org.apache.seatunnel.common.constants.PluginType; -import org.apache.seatunnel.common.utils.JsonUtils; import org.apache.seatunnel.connectors.seatunnel.paimon.sink.PaimonSinkFactory; import org.apache.seatunnel.connectors.seatunnel.paimon.source.PaimonSourceFactory; import org.apache.seatunnel.e2e.common.TestResource; @@ -168,10 +169,13 @@ public void testJsonValidationStdoutAndExitStatus(TestContainer container) throw "--format", "json" }); + ObjectMapper strictJson = + new ObjectMapper().enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS); Assertions.assertEquals(0, valid.getExitCode(), valid.getStdout() + valid.getStderr()); Assertions.assertEquals(1, valid.getStdout().trim().split("\\R").length, valid.getStdout()); Assertions.assertTrue( - JsonUtils.readTree(valid.getStdout().getBytes(StandardCharsets.UTF_8)) + strictJson + .readTree(valid.getStdout().getBytes(StandardCharsets.UTF_8)) .get("valid") .asBoolean()); @@ -188,7 +192,8 @@ public void testJsonValidationStdoutAndExitStatus(TestContainer container) throw Assertions.assertEquals( 1, invalid.getStdout().trim().split("\\R").length, invalid.getStdout()); Assertions.assertFalse( - JsonUtils.readTree(invalid.getStdout().getBytes(StandardCharsets.UTF_8)) + strictJson + .readTree(invalid.getStdout().getBytes(StandardCharsets.UTF_8)) .get("valid") .asBoolean()); Assertions.assertFalse(invalid.getStderr().contains("Config Error"), invalid.getStderr()); From 17762e94b893ff4cc5870a189f057d79dc76ca6e Mon Sep 17 00:00:00 2001 From: Yohanes Date: Thu, 19 Nov 2026 11:29:26 +0800 Subject: [PATCH 9/9] [Test][Core] Cover invalid config JSON launcher output --- .../seatunnel/SeaTunnelConnectorTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java index b70e823719a8..ac1945070f86 100644 --- a/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java +++ b/seatunnel-e2e/seatunnel-core-e2e/seatunnel-starter-e2e/src/test/java/org/apache/seatunnel/core/starter/seatunnel/SeaTunnelConnectorTest.java @@ -18,6 +18,7 @@ package org.apache.seatunnel.core.starter.seatunnel; import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.DeserializationFeature; +import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.JsonNode; import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper; import org.apache.seatunnel.shade.org.apache.commons.lang3.StringUtils; @@ -198,6 +199,33 @@ public void testJsonValidationStdoutAndExitStatus(TestContainer container) throw .asBoolean()); Assertions.assertFalse(invalid.getStderr().contains("Config Error"), invalid.getStderr()); + Container.ExecResult invalidConfig = + container.executeBaseCommand( + new String[] { + "--config", + "/tmp/seatunnel/config/sensitive-validation.conf", + "--check", + "--format", + "json" + }); + String invalidConfigDiagnostics = invalidConfig.getStdout() + invalidConfig.getStderr(); + Assertions.assertEquals(1, invalidConfig.getExitCode(), invalidConfigDiagnostics); + Assertions.assertEquals( + 1, invalidConfig.getStdout().trim().split("\\R").length, invalidConfig.getStdout()); + JsonNode invalidConfigResult = + strictJson.readTree(invalidConfig.getStdout().getBytes(StandardCharsets.UTF_8)); + Assertions.assertFalse(invalidConfigResult.get("valid").asBoolean()); + Assertions.assertTrue( + invalidConfigResult + .at("/errors/0/message") + .asText() + .contains("the configured JDBC URL"), + invalidConfig.getStdout()); + Assertions.assertFalse( + invalidConfigDiagnostics.contains("fixture-password"), invalidConfigDiagnostics); + Assertions.assertFalse( + invalidConfig.getStderr().contains("Config Error"), invalidConfig.getStderr()); + Container.ExecResult invalidText = container.executeBaseCommand( new String[] {