{"record":{"id":"638ef97935642c84","repo":"pentaho/pentaho-kettle","slug":"unable-to-write-nr-of-metadata-values","errorCode":null,"errorMessage":"Unable to write nr of metadata values","messagePattern":"Unable to write nr of metadata values","errorType":"exception","errorClass":"org.pentaho.di.core.exception.KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/RowMeta.java","lineNumber":705,"sourceCode":"    } finally {\n      lock.readLock().unlock();\n    }\n  }\n\n  /**\n   * Write ONLY the specified metadata to the outputStream\n   *\n   * @throws KettleFileException in case things go awry\n   */\n  @Override\n  public void writeMeta( DataOutputStream outputStream ) throws KettleFileException {\n    lock.readLock().lock();\n    try {\n      // First handle the number of fields in a row\n      try {\n        outputStream.writeInt( size() );\n      } catch ( IOException e ) {\n        throw new KettleFileException( \"Unable to write nr of metadata values\", e );\n      }\n\n      // Write all values in the row\n      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();","sourceCodeStart":687,"sourceCodeEnd":723,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/RowMeta.java#L687-L723","documentation":"writeMeta serializes row metadata and first writes an int with the number of fields (size()). If outputStream.writeInt throws IOException, it is wrapped in a KettleFileException \"Unable to write nr of metadata values\". It indicates the metadata transmission failed at the very first word.","triggerScenarios":"Calling RowMeta.writeMeta(outputStream) where the underlying stream throws IOException on the first writeInt: closed stream, broken socket pipe, disk full, or I/O error on a file-backed stream.","commonSituations":"Transferring row metadata between PDI servers when the connection dropped before any bytes were sent; writing metadata to a file that hit quota/disk-full; serializing to a stream already consumed/closed by another thread.","solutions":["Read the chained IOException cause to identify whether it is broken pipe, stream closed, or disk full.","Reconnect or reopen the destination stream and retry writeMeta.","Check available disk space / file permissions when writing metadata to files.","Avoid sharing one OutputStream across threads without synchronization."],"exampleFix":"// before\nrowMeta.writeMeta(outputStream);\n// after\ntry {\n  rowMeta.writeMeta(outputStream);\n} catch (KettleFileException e) {\n  log.error(\"Could not write metadata count: \" + e.getCause(), e);\n  outputStream = reopenStream();\n  rowMeta.writeMeta(outputStream);\n}","handlingStrategy":"retry","validationCode":"if (outputStream == null) { throw new IllegalStateException(\"Output stream is null\"); }\ncheckDiskSpaceIfFileBacked(outputStream);","typeGuard":null,"tryCatchPattern":"try {\n  rowMeta.writeMeta(outputStream);\n  outputStream.flush();\n} catch (KettleFileException e) {\n  log.error(\"Metadata write failed: \" + e.getCause(), e);\n  outputStream = reopenStream();\n  rowMeta.writeMeta(outputStream);\n}","preventionTips":["Verify stream is open/connected before sending metadata.","Monitor disk space for file-backed streams.","Synchronize stream access across threads."],"tags":["io","serialization","row-metadata","stream"],"backgroundTag":"file-write-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"}