{"record":{"id":"0aeee418302a08ec","repo":"pentaho/pentaho-kettle","slug":"invalid-argument-number-0","errorCode":null,"errorMessage":"Invalid argument number [{0}]","messagePattern":"Invalid argument number \\[(.+?)\\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/imp/Import.java","lineNumber":462,"sourceCode":"  }\n\n  /**\n   * Parse an argument as an integer.\n   *\n   * @param option\n   *          Command Line Option to parse argument of\n   * @param def\n   *          Default if the argument is not set\n   * @return The parsed argument or the default if the argument was not specified\n   * @throws KettleException\n   *           Error parsing provided argument as an integer\n   */\n  protected static int parseIntArgument( final CommandLineOption option, final int def ) throws KettleException {\n    if ( !Utils.isEmpty( option.getArgument() ) ) {\n      try {\n        return Integer.parseInt( option.getArgument().toString() );\n      } catch ( NumberFormatException ex ) {\n        throw new KettleException( BaseMessages.getString( PKG, \"Import.Error.InvalidNumberArgument\", option\n          .getOption(), option.getArgument() ) );\n      }\n    }\n    return def;\n  }\n\n  private static void exitJVM( int status ) {\n    System.exit( status );\n  }\n}\n","sourceCodeStart":444,"sourceCodeEnd":473,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/imp/Import.java#L444-L473","documentation":"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.","triggerScenarios":"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.","commonSituations":"Scripting the import with unquoted/interpolated variables that expand to empty or garbage values; copy-pasting options with trailing whitespace or hidden characters.","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()."],"exampleFix":"// before\n// command line: import.sh -retry=$RETRIES  (RETRIES=\"\")\n// after\n// command line: import.sh -retry=${RETRIES:-3}","handlingStrategy":"validation","validationCode":"String raw = option.getArgument() != null ? option.getArgument().toString().trim() : null;\nif (raw != null && !raw.matches(\"\\\\d+\")) {\n  throw new IllegalArgumentException(\"Option \" + option.getOption() + \" needs an integer, got: \" + raw);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Import.main(args);\n} catch (KettleException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid argument number\")) {\n    log.error(\"Fix the numeric CLI option: \" + e.getMessage());\n  } else {\n    throw e;\n  }\n}","preventionTips":["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"],"tags":["cli","number-format","invalid-argument"],"backgroundTag":"invalid-argument-format","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}