pentaho/pentaho-kettle · error · KettleValueException
Unknown value for enum
Error message
Unknown value ${v} for enum ${enumClass} What it means
DefaultInjectionTypeConverter.string2enum converts a string to an enum constant by exact name match across enumClass.getEnumConstants(). When no constant's name() equals the input, Kettle throws KettleValueException. This guards metadata-injection value parsing from silently producing null enums.
Solutions
- Fix the injected value to exactly match an enum constant name (case-sensitive, no whitespace).
- Check the target enum class (printed in the message) for the valid constant names in your Kettle version.
- If values come from an older version, map legacy names to current enum constants before injection.
- If you control the converter pipeline, normalize the string (trim, upper/lower) before conversion.
Example fix
// before
converter.string2enum("Batchl", updateMode.getClass());
// after
converter.string2enum("Batch", updateMode.getClass()); // exact enum name Defensive patterns
Strategy: validation
Validate before calling
boolean valid = java.util.Arrays.stream(MyEnum.values()).anyMatch(e -> e.name().equals(candidateValue));
if (!valid) throw new IllegalArgumentException("Value not a valid " + MyEnum.class.getSimpleName() + ": " + candidateValue); Type guard
static <E extends Enum<E>> boolean isValidEnumValue(Class<E> type, String v) {
if (v == null) return false;
return Arrays.stream(type.getEnumConstants()).anyMatch(e -> e.name().equals(v));
} Try / catch
try {
Enum<?> mode = converter.string2enum(value, MyEnum.class);
} catch (KettleValueException e) {
log.logError("Invalid enum value for injection: " + e.getMessage());
mode = defaultValue;
} Prevention
- Validate injected strings against Enum.values() names before conversion.
- Trim and normalize case of source values before injection.
- Keep enum values consistent between exported metadata and target Kettle version.
- Document accepted values next to the injection field definition.
When it happens
Trigger: Calling string2enum(v, enumClass) (directly or via metadata injection of a field whose converter is the enum converter) with a string that is not an exact enum constant name, including wrong case or trailing whitespace.
Common situations: Importing a transformation exported from a different Pentaho/Kettle version where the enum gained/lost constants; hand-edited XML or injection spreadsheets with misspelled or case-mismatched enum values.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Wrong value conversion to
- Wrong value conversion to
- Calculator.Log.UnknownCalculationType + fn.getCalcType()
- : can't be converted to an Internet Address
- CheckSum.Error.UnknownChecksumType
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/5e9c02f2a40424d7.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/injection/DefaultInjectionTypeConverter.java:71
}
@Override
public Boolean string2boolean( String v ) {
return v == null ? null : string2booleanPrimitive( v );
}
@Override
public Enum<?> string2enum( Class<?> enumClass, String v ) throws KettleValueException {
if ( v == null ) {
return null;
}
for ( Object eo : enumClass.getEnumConstants() ) {
Enum<?> e = (Enum<?>) eo;
if ( e.name().equals( v ) ) {
return e;
}
}
throw new KettleValueException( "Unknown value " + v + " for enum " + enumClass );
}
@Override
public String boolean2string( Boolean v ) throws KettleValueException {
if ( v == null ) {
return null;
}
return v ? "Y" : "N";
}
@Override
public int boolean2intPrimitive( Boolean v ) throws KettleValueException {
return v ? 1 : 0;
}
@Override
public Integer boolean2integer( Boolean v ) throws KettleValueException {
return v == null ? null : boolean2intPrimitive( v );View on GitHub (pinned to f3058517a1)