pentaho/pentaho-kettle · error · KettleException
Invalid argument number
Error message
Invalid argument number [{0}] What it means
Import.parseIntArgument parses a CommandLineOption's argument as an int and throws KettleException "Invalid argument number [{0}]" (Import.Error.InvalidNumberArgument) when Integer.parseInt fails with NumberFormatException. It converts numeric CLI options (e.g. retry counts) into ints, validating user-supplied command line values.
Solutions
- Pass a plain integer for the option, e.g. -retry=3.
- Check shell variables feeding the option — echo them before running to confirm they hold digits only.
- Quote/trim the argument to remove whitespace and stray characters.
- Parse the option manually with your own try/catch to give a friendlier CLI error before calling main().
Example fix
// before
// command line: import.sh -retry=$RETRIES (RETRIES="")
// after
// command line: import.sh -retry=${RETRIES:-3} Defensive patterns
Strategy: validation
Validate before calling
String raw = option.getArgument() != null ? option.getArgument().toString().trim() : null;
if (raw != null && !raw.matches("\\d+")) {
throw new IllegalArgumentException("Option " + option.getOption() + " needs an integer, got: " + raw);
} Try / catch
try {
Import.main(args);
} catch (KettleException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Invalid argument number")) {
log.error("Fix the numeric CLI option: " + e.getMessage());
} else {
throw e;
}
} Prevention
- Quote and default shell variables in scripts: ${VAR:-3}
- Validate numeric CLI inputs with a regex before invoking
- Avoid units or separators in numeric options
When it happens
Trigger: Passing a non-numeric value to a numeric CLI option of the import command, e.g. -retry=abc; passing a number with stray characters, units ("5s"), or locale-formatted digits.
Common situations: Scripting the import with unquoted/interpolated variables that expand to empty or garbage values; copy-pasting options with trailing whitespace or hidden characters.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- A module with id ' ' is not defined.
- Bounds of this rule are not numeric: lowerBound=
- Caught a number format exception converting minimum length…
- Commit size must be an integer.
- Could not apply the given format on the number
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/0aeee418302a08ec.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/imp/Import.java:462
}
/**
* Parse an argument as an integer.
*
* @param option
* Command Line Option to parse argument of
* @param def
* Default if the argument is not set
* @return The parsed argument or the default if the argument was not specified
* @throws KettleException
* Error parsing provided argument as an integer
*/
protected static int parseIntArgument( final CommandLineOption option, final int def ) throws KettleException {
if ( !Utils.isEmpty( option.getArgument() ) ) {
try {
return Integer.parseInt( option.getArgument().toString() );
} catch ( NumberFormatException ex ) {
throw new KettleException( BaseMessages.getString( PKG, "Import.Error.InvalidNumberArgument", option
.getOption(), option.getArgument() ) );
}
}
return def;
}
private static void exitJVM( int status ) {
System.exit( status );
}
}
View on GitHub (pinned to f3058517a1)