{"record":{"id":"1adc2c372dbea091","repo":"pentaho/pentaho-kettle","slug":"there-was-a-data-type-error-the-data-type-of-object-does-not","errorCode":null,"errorMessage":" : There was a data type error: the data type of object [] does not correspond to value meta []","messagePattern":" : There was a data type error: the data type of object \\[\\] does not correspond to value meta \\[\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":3017,"sourceCode":"                    break;\n                  case TYPE_DATE:\n                    writeDate( outputStream, (Date) index[i] );\n                    break;\n                  case TYPE_BIGNUMBER:\n                    writeBigNumber( outputStream, (BigDecimal) index[i] );\n                    break;\n                  case TYPE_BOOLEAN:\n                    writeBoolean( outputStream, (Boolean) index[i] );\n                    break;\n                  case TYPE_BINARY:\n                    writeBinary( outputStream, (byte[]) index[i] );\n                    break;\n                  default:\n                    throw new KettleFileException( toString()\n                        + \" : Unable to serialize indexe storage type for data type \" + getType() );\n                }\n              } catch ( ClassCastException e ) {\n                throw new RuntimeException( toString() + \" : There was a data type error: the data type of \"\n                    + index[i].getClass().getName() + \" object [\" + index[i] + \"] does not correspond to value meta [\"\n                    + toStringMeta() + \"]\" );\n              }\n            }\n          }\n          break;\n\n        case STORAGE_TYPE_BINARY_STRING:\n          // Save the storage meta data...\n          //\n          outputStream.writeBoolean( storageMetadata != null );\n\n          if ( storageMetadata != null ) {\n            storageMetadata.writeMeta( outputStream );\n          }\n          break;\n\n        default:","sourceCodeStart":2999,"sourceCodeEnd":3035,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L2999-L3035","documentation":"RuntimeException thrown inside ValueMetaBase.writeData when an indexed (STORAGE_TYPE_INDEXED) value's element raises ClassCastException during serialization: the element's class does not match the declared index element type. Unlike error 470 this surfaces as a raw RuntimeException because it is thrown from within the per-index-element catch block.","triggerScenarios":"writeData() on an indexed value meta where an index entry fails casts like (String), (Double), (Long), (Date), (Boolean), (byte[]) imposed by the index element's declared type.","commonSituations":"Index arrays built with mixed classes (e.g., Long and Integer mixed); lookup tables populated from queries returning different numeric types than declared; custom plugin code filling the index without conversion.","solutions":["Normalize all index entries to the exact class expected by the value meta's type before writing","Build the indexed ValueMeta with ValueMetaFactory/clone from a correctly typed prototype","Log index position i and the offending class to locate the producer of the wrong-typed entry"],"exampleFix":"// before\nindex[i] = Long.valueOf(5); // meta declares TYPE_INTEGER (expects Integer)\n// after\nif (!(index[i] instanceof Integer)) {\n  index[i] = Integer.valueOf(((Number) index[i]).intValue());\n}","handlingStrategy":"type-guard","validationCode":"// Check each index entry's class against the declared type before writeData:\nstatic boolean indexEntriesMatchType(ValueMetaInterface vmi, Object[] index) {\n  Class<?> expected = expectedClassFor(vmi.getType());\n  for (Object o : index) {\n    if (o != null && !expected.isInstance(o)) return false;\n  }\n  return true;\n}","typeGuard":"static Object normalizeIndexEntry(ValueMetaInterface vmi, Object o) {\n  if (o == null) return null;\n  switch (vmi.getType()) {\n    case ValueMetaInterface.TYPE_STRING: return o instanceof String ? o : String.valueOf(o);\n    case ValueMetaInterface.TYPE_INTEGER: return o instanceof Long ? o : Long.valueOf(((Number) o).longValue());\n    case ValueMetaInterface.TYPE_NUMBER: return o instanceof Double ? o : Double.valueOf(((Number) o).doubleValue());\n    default: return o;\n  }\n}","tryCatchPattern":"try {\n  valueMeta.writeData(out, object);\n} catch (RuntimeException e) {\n  if (String.valueOf(e.getMessage()).contains(\"data type error\")) {\n    LOG.error(\"Indexed field \" + valueMeta.getName() + \": entry class mismatch - \" + e.getMessage());\n    // rebuild the index array with normalized entries, then retry\n  } else { throw e; }\n}","preventionTips":["Populate index arrays from a single typed source; never mix Integer/Long or Date/Timestamp entries","Normalize entries with a shared converter when building indexed value metas","Catch RuntimeException, not just KettleFileException, when writing indexed values — this path throws unchecked","Add a round-trip serialization test for each indexed lookup table in your transformations"],"tags":["kettle","pdi","serialization","indexed-storage","classcastexception","type-mismatch"],"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"}