{"record":{"id":"78ead176c96e7cae","repo":"pentaho/pentaho-kettle","slug":"error-reading-from-data-input-stream","errorCode":null,"errorMessage":"Error reading from data input stream","messagePattern":"Error reading from data input stream","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/compatibility/Value.java","lineNumber":1641,"sourceCode":"      }\n    }\n  }\n\n  /**\n   * Read the Value, including meta-data from a DataInputStream\n   *\n   * @param is\n   *          The InputStream to read the value from\n   * @throws KettleFileException\n   *           when the Value couldn't be created by reading it from the DataInputStream.\n   */\n  public Value( InputStream is ) throws KettleFileException {\n    try {\n      readObj( new DataInputStream( is ) );\n    } catch ( EOFException e ) {\n      throw new KettleEOFException( \"End of file reached\", e );\n    } catch ( Exception e ) {\n      throw new KettleFileException( \"Error reading from data input stream\", e );\n    }\n  }\n\n  /**\n   * Write the data of this Value, without the meta-data to a DataOutputStream\n   *\n   * @param dos\n   *          The DataOutputStream to write the data to\n   * @return true if all went well, false if something went wrong.\n   */\n  public boolean writeData( DataOutputStream dos ) throws KettleFileException {\n    try {\n      // Is the value NULL?\n      dos.writeBoolean( isNull() );\n\n      // Handle Content -- only when not NULL\n      if ( !isNull() ) {\n        switch ( getType() ) {","sourceCodeStart":1623,"sourceCodeEnd":1659,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/compatibility/Value.java#L1623-L1659","documentation":"This KettleFileException is thrown by the Value(InputStream) constructor when readObj() fails with any exception other than EOFException during deserialization. It signals a corruption or format problem while reading the serialized Value (bad type tag, invalid UTF data, unexpected primitive, etc.) rather than a simple end-of-stream.","triggerScenarios":"new Value( InputStream ) when the stream bytes do not match the expected Value serialization format: corrupted data files, wrong file type passed in, a writer using an incompatible serialization version, or encrypted/compressed data read as raw.","commonSituations":"Pointing the reader at a non-Kettle file; reading a file written by a different PDI version with a changed wire format; bit-rot or partial gzip decompression feeding the stream; passing a plain-text stream instead of a DataInputStream-compatible binary stream.","solutions":["Verify the stream contains genuine Kettle-serialized Value data (check file header/magic and provenance).","Ensure writer and reader use compatible Pentaho/Kettle versions; re-export the data if formats differ.","Check for compression/encryption — wrap the stream in the matching GZIPInputStream/CipherInputStream before passing it in.","Validate the file integrity (checksum) and regenerate it if corrupted.","Catch KettleFileException and log the underlying cause (e.getCause()) to pinpoint which primitive read failed."],"exampleFix":"// before\nValue v = new Value( new FileInputStream( file ) ); // may throw KettleFileException\n// after\ntry ( InputStream in = new GZIPInputStream( new FileInputStream( file ) ) ) {\n  Value v = new Value( in );\n} catch ( KettleFileException e ) {\n  throw new IOException( \"Corrupt or incompatible value data in \" + file, e );\n}","handlingStrategy":"try-catch","validationCode":"// sanity-check the source before deserializing\nFile f = new File( path );\nif ( !f.isFile() || f.length() == 0 ) throw new IOException( \"Missing or empty data file: \" + path );\n// verify checksum recorded at write time\nif ( expectedMd5 != null && !md5Of( f ).equals( expectedMd5 ) ) throw new IOException( \"Checksum mismatch: \" + path );","typeGuard":"boolean looksLikeKettleBinary( InputStream in ) throws IOException {\n  in.mark( 16 );\n  int b = in.read();\n  in.reset();\n  return b != -1; // plus any known magic-byte check for your format\n}","tryCatchPattern":"try {\n  Value v = new Value( in );\n} catch ( KettleFileException e ) {\n  throw new IOException( \"Corrupt/incompatible value data: \" + e.getCause(), e );\n}","preventionTips":["Verify file provenance and format before deserialization.","Wrap compressed/encrypted streams with the correct stream decorators.","Align serialization format versions between writer and reader.","Record and check checksums on data files.","Log e.getCause() to identify the failing primitive read."],"tags":["io","deserialization","corruption"],"backgroundTag":"file-read-failed","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"}