{"record":{"id":"0e02c54839188e5d","repo":"pentaho/pentaho-kettle","slug":"tostring-couldn-t-convert-string-to-integer-value-out-of","errorCode":null,"errorMessage":"<toString()> : couldn't convert String to Integer : value Out of Range [<string>]. Change the destination data type or round to the nearest value possible for Integer by setting property KETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION to \"Y\". ","messagePattern":"<toString\\(\\)> : couldn't convert String to Integer : value Out of Range \\[<string>\\]\\. Change the destination data type or round to the nearest value possible for Integer by setting property KETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION to \"Y\"\\. ","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":1351,"sourceCode":"      Number number;\n      if ( lenientStringToNumber ) {\n        number = getDecimalFormat( false ).parse( string );\n      } else {\n        ParsePosition parsePosition = new ParsePosition( 0 );\n        number = getDecimalFormat( false ).parse( string, parsePosition );\n\n        if ( parsePosition.getIndex() < string.length() ) {\n          throw new KettleValueException( toString()\n            + \" : couldn't convert String to number : non-numeric character found at position \"\n            + ( parsePosition.getIndex() + 1 ) + \" for value [\" + string + \"]\" );\n        }\n      }\n\n      if ( number instanceof Double && ( number.doubleValue() < Long.MIN_VALUE\n        || number.doubleValue() > Long.MAX_VALUE ) ) {\n        log.logBasic( \"Value [\" + string + \"] is out of range for Integer.\" );\n        if ( !ignoreOutOfRange ) {\n          throw new KettleValueException( toString()\n            + \" : couldn't convert String to Integer : value Out of Range [\" + string\n            + \"]. Change the destination data type or round to the nearest value possible for Integer by setting \"\n            + \"property KETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION to \\\"Y\\\". \" );\n        }\n      }\n\n      return new Long( number.longValue() );\n    } catch ( Exception e ) {\n      throw new KettleValueException( toString() + \" : couldn't convert String to Integer\", e );\n    }\n  }\n\n  protected synchronized String convertBigNumberToString( BigDecimal number ) throws KettleValueException {\n    if ( number == null ) {\n      return null;\n    }\n\n    try {","sourceCodeStart":1333,"sourceCodeEnd":1369,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L1333-L1369","documentation":"Thrown by ValueMetaBase.convertStringToInteger when a parsed number's Double value falls outside Long.MIN_VALUE/MAX_VALUE range and the KETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION property is not set to 'Y'. Pentaho Kettle (PDI) refuses to silently truncate the integer, so conversion aborts with a KettleValueException. The value name is prefixed by toString() so you can identify which field failed.","triggerScenarios":"convertStringToInteger(String) called via ValueMeta.getString→Integer conversion (or convertRowToNativeType) where the string parses as a Double exceeding Long range, e.g. '9223372036854775808' or '1E30', and system property KETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION != 'Y'.","commonSituations":"Reading text/CSV files whose numeric column overflows Long; loading data from systems with wider numeric types (e.g. Oracle NUMBER, big counters) into a Kettle Integer field; scientific-notation strings like '1e25'.","solutions":["Fix the source value or widen the field type to BigNumber (TYPE_NUMBER/TYPE_BIGNUMBER) so no Long truncation is needed.","Set JVM system property -DKETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION=Y to truncate to the nearest representable value instead of throwing.","Pre-validate/pre-process the string in a JavaScript/UDJE step to clamp values into Long range before the conversion.","Use a Select Values step to change the field's metadata to String or BigNumber before the row is converted to Integer."],"exampleFix":"// before: field typed as Integer, value '99999999999999999999' overflows\n// after: change value meta to BigNumber in a Select Values / Java Script step\nValueMetaInterface vmi = new ValueMetaNumber(\"amount\");\nvmi.setConversionMask(\"#\"); // or declare the column as BigNumber in the CSV input step\n// alternative: JVM arg\n// -DKETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION=Y","handlingStrategy":"validation","validationCode":"double d = Double.parseDouble(s);\nif (d < Long.MIN_VALUE || d > Long.MAX_VALUE) {\n    throw new IllegalArgumentException(\"Value out of Long/Integer range: \" + s);\n}","typeGuard":"static boolean fitsInLong(double d) { return d >= Long.MIN_VALUE && d <= Long.MAX_VALUE && !Double.isNaN(d); }","tryCatchPattern":"try {\n    long v = valueMeta.getInteger(s);\n} catch (KettleValueException e) {\n    // fall back to BigDecimal storage\n    BigDecimal bd = valueMeta.getBigNumber(s);\n}","preventionTips":["Type wide numeric columns as BigNumber instead of Integer in input steps","Set -DKETTLE_IGNORE_OUT_OF_RANGE_EXCEPTION=Y when truncation is acceptable","Validate numeric ranges at the boundary (file/db input) before conversion"],"tags":["pdi","type-conversion","integer-overflow","kettle"],"backgroundTag":"value-out-of-range","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"}