pentaho/pentaho-kettle · error · KettleValueException
<toString()> : couldn't convert Long to String
Error message
<toString()> : couldn't convert Long to String
What it means
Thrown by ValueMetaBase's Long/Integer-to-String conversion when getDecimalFormat(false).format(integer) throws. It wraps the cause and names the value meta, meaning the integer could not be formatted to a string under the current format mask and locale.
Solutions
- Verify the conversion mask is a valid DecimalFormat pattern for integers (e.g. '#,##0')
- Clear the mask to use the default formatting if none is required
- Align setConversionLocale with the mask's separators
- Catch KettleValueException and fall back to String.valueOf(long)
Example fix
// before
valueMeta.setConversionMask("#,##0.00E0;;"); // invalid for Integer
// after
valueMeta.setConversionMask("#,##0"); Defensive patterns
Strategy: try-catch
Validate before calling
static boolean isValidIntegerMask(String mask) {
try { new java.text.DecimalFormat(mask); return true; }
catch (IllegalArgumentException e) { return false; }
} Try / catch
try {
String s = valueMeta.getString(longObject);
} catch (KettleValueException e) {
log.error("Long->String format failed: " + e.getMessage(), e);
return String.valueOf(longObject);
} Prevention
- Use integer-appropriate masks like '#,##0' (no decimal sections)
- Clear the conversion mask when default formatting is acceptable
- Keep mask and ConversionLocale consistent
- Test formatting after loading metadata from older files
When it happens
Trigger: Calling getString() on a TYPE_INTEGER value when DecimalFormat.format(Long) fails — invalid conversion mask pattern, incompatible mask/locale combination, or an exception raised inside the DecimalFormat.
Common situations: Masks containing invalid pattern characters copied from a Number field; locale changed after masks were defined; corrupted value meta metadata loaded from an old file.
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
- <toString()> : couldn't convert Number to String
- <toString()> : couldn't convert String to number …
- e.toString()
- <toString()> : couldn't convert string
- <toString()> : couldn't convert String to number with…
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/c36e281c0b989871.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:1312
return null;
} else {
// Return strings padded to the specified length...
// This is done for backward compatibility with 2.5.x
// We just optimized this a bit...
//
String[] emptyPaddedStrings = Const.getEmptyPaddedStrings();
if ( length < emptyPaddedStrings.length ) {
return emptyPaddedStrings[length];
} else {
return Const.rightPad( "", length );
}
}
}
try {
return getDecimalFormat( false ).format( integer );
} catch ( Exception e ) {
throw new KettleValueException( toString() + " : couldn't convert Long to String ", e );
}
}
protected synchronized String convertIntegerToCompatibleString( Long integer ) throws KettleValueException {
if ( integer == null ) {
return null;
}
return Long.toString( integer );
}
protected synchronized Long convertStringToInteger( String string ) throws KettleValueException {
string = Const.trimToType( string, getTrimType() ); // see if trimming needs
// to be performed before
// conversion
if ( Utils.isEmpty( string ) ) {
return null;
}View on GitHub (pinned to f3058517a1)