pentaho/pentaho-kettle · error · KettleException
SwitchCase.Log.UnableToConvertValue
SwitchCase.Log.UnableToConvertValue
Error message
SwitchCase.Log.UnableToConvertValue
What it means
KettleException thrown by SwitchCase.createOutputValueMapping when converting the configured case value (stored as a string in metadata) to the data type of the switch field fails via data.valueMeta.convertDataFromString, or when the subsequent value preparation throws. The message includes the offending case value. This makes the case value and the field type mismatch fatal at startup of the step.
Solutions
- Make each case value exactly convertible to the switch field's data type (e.g., '1' not 'one' for Integer fields).
- Align date/number conversion masks in the field's value metadata with the format of the case values.
- Trim spaces and normalize the format of case values in the dialog.
- If the field type changed upstream, update the field metadata and all case values, then re-save.
Example fix
// before: non-numeric case value on an Integer field caseValue = "one"; // after caseValue = "1";
Defensive patterns
Strategy: validation
Validate before calling
// check each case value converts to the switch field's type
ValueMetaInterface vm = inputRowMeta.getValueMeta( inputRowMeta.indexOfValue( meta.getFieldname() ) );
for ( SwitchCaseTarget t : meta.getCaseTargets() ) {
try { vm.convertDataFromString( t.getCaseValue(), new ValueMetaString( "v" ), null, null, 0 ); }
catch ( Exception e ) { throw new KettleException( "Case value not convertible: " + t.getCaseValue(), e ); }
} Try / catch
try { run(); } catch ( KettleException e ) { if ( e.getMessage().contains( "UnableToConvertValue" ) ) log.error( "Fix case value formats to match field type" ); throw e; } Prevention
- Match case value format to the field's conversion mask (dates, numbers).
- Trim whitespace from case values.
- Align JVM locales between designer and server.
- Re-enter case values after changing the switch field's data type.
When it happens
Trigger: A case value like 'abc' against a numeric/Integer switch field, malformed dates ('13/45/2024') against a Date field, locale-dependent number formats, or empty case-value strings against non-string fields — any Exception from convertDataFromString inside the per-target loop.
Common situations: Changing the switch field's data type upstream (e.g., String to Integer) without updating case values; entering dates in a format not matching the field's conversion mask; copy-pasting case values with stray spaces; locale differences between designer and server JVMs.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- SwitchCase.Exception.UnableToFindFieldName
- SwitchCase.Log.NoTargetStepSpecifiedForValue
- : can't be converted to an Internet Address
- ERROR_ARITHMETIC_VALUE
- Error converting data while looking up value
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/32a050d37cedd979.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/switchcase/SwitchCase.java:199
}
try {
Object value =
data.valueMeta.convertDataFromString(
target.caseValue, data.stringValueMeta, null, null, ValueMetaInterface.TRIM_TYPE_NONE );
// If we have a value and a rowset, we can store the combination in the map
//
if ( data.valueMeta.isNull( value ) ) {
data.nullRowSetSet.add( rowSet );
} else {
// could not use byte[] as key in Maps, so we need to convert it to his specific hashCode for future
// comparisons
value = prepareObjectType( value );
data.outputMap.put( value, rowSet );
}
} catch ( Exception e ) {
throw new KettleException( BaseMessages.getString(
PKG, "SwitchCase.Log.UnableToConvertValue", target.caseValue ), e );
}
}
if ( meta.getDefaultTargetStep() != null ) {
RowSet rowSet = findOutputRowSet( meta.getDefaultTargetStep().getName() );
if ( rowSet != null ) {
data.defaultRowSetSet.add( rowSet );
if ( data.nullRowSetSet.isEmpty() ) {
data.nullRowSetSet.add( rowSet );
}
}
}
} catch ( Exception e ) {
throw new KettleException( e );
}
}
View on GitHub (pinned to f3058517a1)