{"record":{"id":"175e9834a9164efe","repo":"pentaho/pentaho-kettle","slug":"i-can-t-convert-the-specified-value-to-data-type","errorCode":null,"errorMessage":" : I can't convert the specified value to data type : ","messagePattern":" : I can't convert the specified value to data type : ","errorType":"exception","errorClass":"KettleValueException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":3883,"sourceCode":"  public Object convertData( ValueMetaInterface meta2, Object data2 ) throws KettleValueException {\n    switch ( getType() ) {\n      case TYPE_NONE:\n      case TYPE_STRING:\n        return meta2.getString( data2 );\n      case TYPE_NUMBER:\n        return meta2.getNumber( data2 );\n      case TYPE_INTEGER:\n        return meta2.getInteger( data2 );\n      case TYPE_DATE:\n        return meta2.getDate( data2 );\n      case TYPE_BIGNUMBER:\n        return meta2.getBigNumber( data2 );\n      case TYPE_BOOLEAN:\n        return meta2.getBoolean( data2 );\n      case TYPE_BINARY:\n        return meta2.getBinary( data2 );\n      default:\n        throw new KettleValueException( toString() + \" : I can't convert the specified value to data type : \"\n            + getType() );\n    }\n  }\n\n  /**\n   * Convert the specified data to the data type specified in this object. For String conversion, be compatible with\n   * version 2.5.2.\n   *\n   * @param meta2\n   *          the metadata of the object to be converted\n   * @param data2\n   *          the data of the object to be converted\n   * @return the object in the data type of this value metadata object\n   * @throws KettleValueException\n   *           in case there is a data conversion error\n   */\n  @Override\n  public Object convertDataCompatible( ValueMetaInterface meta2, Object data2 ) throws KettleValueException {","sourceCodeStart":3865,"sourceCodeEnd":3901,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L3865-L3901","documentation":"ValueMetaBase.convertData(meta2, data2) converts data2 to this value's type by calling the corresponding getter on meta2 (getString/getNumber/.../getBinary). If this meta's type code is not one of the seven supported types (including TYPE_NONE), the default branch throws this KettleValueException. It means conversion was requested toward an undefined or unsupported target data type.","triggerScenarios":"Calling convertData(ValueMetaInterface, Object) when this meta's getType() is TYPE_NONE or any type code outside STRING/NUMBER/INTEGER/DATE/BIGNUMBER/BOOLEAN/BINARY.","commonSituations":"ValueMeta constructed without a type (new ValueMeta(\"x\")); cross-type row conversion in steps like Stream Lookup or Update where target metadata was never initialized; plugin fields with custom type codes unknown to core conversion.","solutions":["Set a valid type on the target metadata before conversion: setType(ValueMetaInterface.TYPE_STRING) or another supported type.","Guard with getType() checks and skip/convert unsupported fields upstream (Select Values / Metadata step).","Replace TYPE_NONE metadata with concrete metadata derived from source rows (clone a properly typed ValueMeta).","If a plugin introduces exotic types, map them to core types before using convertData."],"exampleFix":"// before\nValueMetaInterface target = new ValueMeta(\"out\"); // TYPE_NONE\nObject v = target.convertData(sourceMeta, data); // throws\n\n// after\nValueMetaInterface target = new ValueMeta(\"out\", ValueMetaInterface.TYPE_STRING);\nObject v = target.convertData(sourceMeta, data);","handlingStrategy":"validation","validationCode":"if (target.getType() == ValueMetaInterface.TYPE_NONE) {\n  throw new IllegalStateException(\"Target \" + target.toStringMeta() + \" has no type for convertData\");\n}","typeGuard":"boolean isConvertibleTarget(ValueMetaInterface m) {\n  int t = m.getType();\n  return t == ValueMetaInterface.TYPE_STRING || t == ValueMetaInterface.TYPE_NUMBER\n      || t == ValueMetaInterface.TYPE_INTEGER || t == ValueMetaInterface.TYPE_DATE\n      || t == ValueMetaInterface.TYPE_BIGNUMBER || t == ValueMetaInterface.TYPE_BOOLEAN\n      || t == ValueMetaInterface.TYPE_BINARY;\n}","tryCatchPattern":"try { Object v = target.convertData(sourceMeta, data); } catch (KettleValueException e) {\n  if (e.getMessage().contains(\"I can't convert\")) {\n    target.setType(ValueMetaInterface.TYPE_STRING);\n    Object v = target.convertData(sourceMeta, data);\n  } else throw e;\n}","preventionTips":["Always pass an explicit type to the ValueMeta constructor.","Validate target types before conversion loops over row metadata.","Map plugin-specific type codes to core types first."],"tags":["pdi","kettle","conversion","data-type"],"backgroundTag":"unsupported-operation","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"}