{"record":{"id":"f8a441c6a56e0094","repo":"pentaho/pentaho-kettle","slug":"end-of-file-while-reading-the-number-of-metadata-values-in","errorCode":null,"errorMessage":"End of file while reading the number of metadata values in the row metadata","messagePattern":"End of file while reading the number of metadata values in the row metadata","errorType":"exception","errorClass":"org.pentaho.di.core.exception.KettleEOFException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/RowMeta.java","lineNumber":727,"sourceCode":"      for ( int i = 0; i < size(); i++ ) {\n        getValueMeta( i ).writeMeta( outputStream );\n      }\n    } finally {\n      lock.readLock().unlock();\n    }\n\n  }\n\n  public RowMeta( DataInputStream inputStream ) throws KettleFileException, SocketTimeoutException {\n    this();\n\n    int nr;\n    try {\n      nr = inputStream.readInt();\n    } catch ( SocketTimeoutException e ) {\n      throw e;\n    } catch ( EOFException e ) {\n      throw new KettleEOFException(\n        \"End of file while reading the number of metadata values in the row metadata\", e );\n    } catch ( IOException e ) {\n      throw new KettleFileException( \"Unable to read nr of metadata values: \" + e.toString(), e );\n    }\n\n    for ( int i = 0; i < nr; i++ ) {\n      try {\n        int type = inputStream.readInt();\n        ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta( type );\n        valueMeta.readMetaData( inputStream );\n        addValueMeta( valueMeta );\n      } catch ( EOFException e ) {\n        throw new KettleEOFException( e );\n      } catch ( Exception e ) {\n        throw new KettleFileException( toString() + \" : Unable to read row metadata from input stream\", e );\n      }\n\n    }","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/RowMeta.java#L709-L745","documentation":"This constructor reads row metadata from an InputStream, starting with an int field count. An EOFException on that first readInt means the stream ended before any metadata could be read, so it is rethrown as KettleEOFException with an explicit message. SocketTimeoutException is deliberately rethrown unchanged so callers can retry socket reads.","triggerScenarios":"Deserializing RowMeta from a stream that is already at EOF: empty file, zero-length socket message, peer closed the connection before sending metadata, or reading past the end of a truncated file.","commonSituations":"PDI slave server receiving an empty/truncated stream from master; reading a metadata cache file that was cut short by an earlier failed write; a network peer crashing mid-handshake.","solutions":["Check the sending side: it likely wrote nothing or the write failed (look for paired writeMeta exceptions).","Verify the stream/file is not empty and contains complete serialized metadata before reading.","Re-transmit the metadata after re-establishing the connection.","For files, compare file size against expected metadata length to detect truncation and regenerate the file."],"exampleFix":"// before\nRowMeta rowMeta = new RowMeta(inputStream); // throws KettleEOFException on empty stream\n// after\nif (inputStream.available() <= 0) {\n  throw new KettleException(\"Peer sent no row metadata; requesting resend\");\n}\ntry {\n  RowMeta rowMeta = new RowMeta(inputStream);\n} catch (KettleEOFException e) {\n  log.error(\"Truncated metadata stream\", e);\n  requestMetadataResend();\n}","handlingStrategy":"validation","validationCode":"if (inputStream == null || inputStream.available() <= 0) {\n  throw new KettleException(\"No metadata bytes available on input stream\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  RowMeta rowMeta = new RowMeta(inputStream);\n} catch (KettleEOFException e) {\n  log.error(\"Empty/truncated metadata stream\", e);\n  requestMetadataResend();\n}","preventionTips":["Confirm the sender completed its write before reading.","Check file sizes against expected metadata lengths to detect truncation.","Handle SocketTimeoutException separately as a retryable condition."],"tags":["io","eof","deserialization","row-metadata"],"backgroundTag":"unexpected-eof","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"}