diff --git a/besu/src/main/java/org/hyperledger/besu/cli/util/TomlConfigurationDefaultProvider.java b/besu/src/main/java/org/hyperledger/besu/cli/util/TomlConfigurationDefaultProvider.java index a346e260d13..1747f461dc4 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/util/TomlConfigurationDefaultProvider.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/util/TomlConfigurationDefaultProvider.java @@ -50,6 +50,7 @@ public class TomlConfigurationDefaultProvider implements IDefaultValueProvider { private final CommandLine commandLine; private final InputStream configurationInputStream; private TomlParseResult result; + private boolean isUnknownOptionsChecked; /** * Instantiates a new Toml config file default value provider. @@ -230,6 +231,11 @@ private void checkConfigurationValidity() { throw new ParameterException( commandLine, String.format("Unable to read TOML configuration file %s", configurationInputStream)); + + if (!isUnknownOptionsChecked && !commandLine.isUnmatchedArgumentsAllowed()) { + checkUnknownOptions(result); + isUnknownOptionsChecked = true; + } } /** Load configuration from file. */ @@ -249,8 +255,6 @@ public void loadConfigurationFromFile() { commandLine, String.format("Invalid TOML configuration: %s", errors)); } - checkUnknownOptions(result); - this.result = result; } catch (final IOException e) {