{"record":{"id":"104de7bd50e42938","repo":"pentaho/pentaho-kettle","slug":"caught-a-number-format-exception-converting-minimum-length","errorCode":null,"errorMessage":"Caught a number format exception converting minimum length with value ","messagePattern":"Caught a number format exception converting minimum length with value ","errorType":"validation","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/validator/Validator.java","lineNumber":626,"sourceCode":"          data.startStringNotAllowed[ i ] =\n            environmentSubstitute( Const.NVL( field.getStartStringNotAllowed(), \"\" ) );\n          data.endStringNotAllowed[ i ] = environmentSubstitute( Const.NVL( field.getEndStringNotAllowed(), \"\" ) );\n          data.regularExpression[ i ] = environmentSubstitute( Const.NVL( field.getRegularExpression(), \"\" ) );\n          data.regularExpressionNotAllowed[ i ] =\n            environmentSubstitute( Const.NVL( field.getRegularExpressionNotAllowed(), \"\" ) );\n\n          ValueMetaInterface stringMeta = cloneValueMeta( data.constantsMeta[ i ], ValueMetaInterface.TYPE_STRING );\n          data.minimumValue[ i ] =\n            Utils.isEmpty( data.minimumValueAsString[ i ] ) ? null : data.constantsMeta[ i ].convertData(\n              stringMeta, data.minimumValueAsString[ i ] );\n          data.maximumValue[ i ] =\n            Utils.isEmpty( data.maximumValueAsString[ i ] ) ? null : data.constantsMeta[ i ].convertData(\n              stringMeta, data.maximumValueAsString[ i ] );\n\n          try {\n            data.fieldsMinimumLengthAsInt[ i ] = Integer.valueOf( Const.NVL( data.minimumLength[ i ], \"-1\" ) );\n          } catch ( NumberFormatException nfe ) {\n            throw new KettleValueException(\n              \"Caught a number format exception converting minimum length with value \"\n                + data.minimumLength[ i ] + \" to an int.\", nfe );\n          }\n\n          try {\n            data.fieldsMaximumLengthAsInt[ i ] = Integer.valueOf( Const.NVL( data.maximumLength[ i ], \"-1\" ) );\n          } catch ( NumberFormatException nfe ) {\n            throw new KettleValueException(\n              \"Caught a number format exception converting minimum length with value \"\n                + data.maximumLength[ i ] + \" to an int.\", nfe );\n          }\n\n          int listSize = field.getAllowedValues() != null ? field.getAllowedValues().length : 0;\n          data.listValues[ i ] = new Object[ listSize ];\n          for ( int s = 0; s < listSize; s++ ) {\n            data.listValues[ i ][ s ] =\n              Utils.isEmpty( field.getAllowedValues()[ s ] ) ? null : data.constantsMeta[ i ].convertData(\n                stringMeta, environmentSubstitute( field.getAllowedValues()[ s ] ) );","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/validator/Validator.java#L608-L644","documentation":"Thrown from Validator.init() when the configured minimum length for a validation cannot be parsed as an integer. The step converts the string setting (minimumLength) to int during initialization and wraps the NumberFormatException in a KettleValueException including the offending value.","triggerScenarios":"init() executing Integer.valueOf(Const.NVL(data.minimumLength[i], \"-1\")) where minimumLength is a non-numeric, non-empty string like 'ten', '5x', or contains whitespace/spaces.","commonSituations":"Typing non-numeric text into the min-length field; pasting values with trailing spaces or locale-formatted numbers ('3,'); variables used but not resolved to numbers at runtime; importing settings with bad values.","solutions":["Open the Validator step and set minimum length to a plain integer (or leave blank for no limit).","Check for hidden whitespace/special characters; retype the value.","If a variable is used, ensure it resolves to an integer at runtime (e.g. ${MINLEN}=5).","Fix the same pattern for maximum length and min/max value fields, which follow the identical conversion path.","Pre-validate settings programmatically: parse each length with Integer.parseInt and fail fast with a clear message."],"exampleFix":"// before (config value)\nfield.setMinimumLength(\"ten\");\n// after\nfield.setMinimumLength(\"10\");\n// caller-side guard\ntry { Integer.parseInt(v); } catch (NumberFormatException e) { throw new IllegalArgumentException(\"min length must be an integer\"); }","handlingStrategy":"validation","validationCode":"// Before execution: lengths must parse as integers\nfor (Validation v : meta.getValidations()) {\n  for (String s : new String[]{ v.getMinimumLength(), v.getMaximumLength() }) {\n    if (!Utils.isEmpty(s)) {\n      try { Integer.parseInt(s.trim()); }\n      catch (NumberFormatException e) { throw new IllegalStateException(\"Length not an integer: '\" + s + \"'\"); }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  trans.startThreads(); // init() triggers the conversion\n} catch (KettleValueException e) {\n  if (e.getMessage().contains(\"number format exception converting minimum length\")) {\n    String bad = e.getMessage().replaceAll(\".*value (.+) to an int.*\", \"$1\");\n    logError(\"Fix min length value: \" + bad);\n  }\n}","preventionTips":["Enter plain integers (or leave blank) in length fields","Avoid locale-formatted numbers and stray spaces","If using variables, guarantee they resolve to integers at runtime","Validate all numeric settings before executing transformations"],"tags":["kettle","validator","number-format","config"],"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"}