{"record":{"id":"38525defc7e3a5de","repo":"pentaho/pentaho-kettle","slug":"wrong-value-conversion-to-destinationtype","errorCode":null,"errorMessage":"Wrong value conversion to <destinationType>","messagePattern":"Wrong value conversion to <destinationType>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/RowMetaAndData.java","lineNumber":376,"sourceCode":"        Boolean vb = rowMeta.getBoolean( data, idx );\n        if ( String.class.isAssignableFrom( destinationType ) ) {\n          return converter.boolean2string( vb );\n        } else if ( int.class.isAssignableFrom( destinationType ) ) {\n          return converter.boolean2intPrimitive( vb );\n        } else if ( Integer.class.isAssignableFrom( destinationType ) ) {\n          return converter.boolean2integer( vb );\n        } else if ( long.class.isAssignableFrom( destinationType ) ) {\n          return converter.boolean2longPrimitive( vb );\n        } else if ( Long.class.isAssignableFrom( destinationType ) ) {\n          return converter.boolean2long( vb );\n        } else if ( boolean.class.isAssignableFrom( destinationType ) ) {\n          return converter.boolean2booleanPrimitive( vb );\n        } else if ( Boolean.class.isAssignableFrom( destinationType ) ) {\n          return converter.boolean2boolean( vb );\n        } else if ( destinationType.isEnum() ) {\n          return converter.boolean2enum( destinationType, vb );\n        } else {\n          throw new RuntimeException( \"Wrong value conversion to \" + destinationType );\n        }\n      case ValueMetaInterface.TYPE_INTEGER:\n        Long vi = rowMeta.getInteger( data, idx );\n        if ( String.class.isAssignableFrom( destinationType ) ) {\n          return converter.integer2string( vi );\n        } else if ( int.class.isAssignableFrom( destinationType ) ) {\n          return converter.integer2intPrimitive( vi );\n        } else if ( Integer.class.isAssignableFrom( destinationType ) ) {\n          return converter.integer2integer( vi );\n        } else if ( long.class.isAssignableFrom( destinationType ) ) {\n          return converter.integer2longPrimitive( vi );\n        } else if ( Long.class.isAssignableFrom( destinationType ) ) {\n          return converter.integer2long( vi );\n        } else if ( boolean.class.isAssignableFrom( destinationType ) ) {\n          return converter.integer2booleanPrimitive( vi );\n        } else if ( Boolean.class.isAssignableFrom( destinationType ) ) {\n          return converter.integer2boolean( vi );\n        } else if ( destinationType.isEnum() ) {","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/RowMetaAndData.java#L358-L394","documentation":"In getAsJavaType(), when the source field is a Boolean (TYPE_BOOLEAN), all supported destination conversions (String, boolean primitive, Boolean, enum) are tried via the converter; if destinationType matches none, a RuntimeException 'Wrong value conversion to <type>' is thrown. It's the per-type fallthrough guard for unsupported target types.","triggerScenarios":"Injecting a Boolean source field into a destinationType like int, Double, Date, Map, or any class not supported by boolean2* converter methods.","commonSituations":"Metadata injection where step property type changed between Kettle versions (e.g. from boolean to int) and the mapping still injects booleans; injecting into custom step setters with unsupported types.","solutions":["Change the destination property type to a supported one (String, boolean/Boolean, enum)","Extend the InjectionTypeConverter with a boolean2X conversion for the needed type","Change the source field type (e.g. encode the boolean as 0/1 integer) to match the target","Catch RuntimeException and report which field/type combination is unsupported"],"exampleFix":"// before\nrow.getAsJavaType(\"flag\", int.class, converter); // boolean source\n// after\nrow.getAsJavaType(\"flag\", Boolean.class, converter);","handlingStrategy":"type-guard","validationCode":"if (row.getRowMeta().getValueMeta(idx).getType() == ValueMetaInterface.TYPE_BOOLEAN) {\n  if (!(String.class.isAssignableFrom(destType) || destType == boolean.class\n      || Boolean.class.isAssignableFrom(destType) || destType.isEnum())) {\n    throw new IllegalArgumentException(\"Unsupported boolean destination: \" + destType);\n  }\n}","typeGuard":"boolean isSupportedBooleanDestination(Class<?> t) {\n  return String.class.isAssignableFrom(t) || t == boolean.class\n    || Boolean.class.isAssignableFrom(t) || t.isEnum();\n}","tryCatchPattern":"try {\n  Object v = row.getAsJavaType(name, destType, converter);\n} catch (RuntimeException e) {\n  if (e.getMessage().startsWith(\"Wrong value conversion\")) {\n    log.error(\"Boolean field \" + name + \" cannot convert to \" + destType, e);\n  } else throw e;\n}","preventionTips":["Keep boolean fields mapped only to String/boolean/Boolean/enum targets","Re-check step property types after upgrading Pentaho versions","Add converter support or type mapping tests for custom destinations"],"tags":["kettle","metadata-injection","type-conversion","boolean"],"backgroundTag":"type-mismatch","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"}