{"record":{"id":"e05f87b82157f01a","repo":"pentaho/pentaho-kettle","slug":"unable-to-write-value-metadata-to-output-stream","errorCode":null,"errorMessage":" : Unable to write value metadata to output stream","messagePattern":" : Unable to write value metadata to output stream","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":3089,"sourceCode":"      // Sorting information\n      outputStream.writeBoolean( sortedDescending );\n\n      // Padding information\n      outputStream.writeBoolean( outputPaddingEnabled );\n\n      // date format lenient?\n      outputStream.writeBoolean( dateFormatLenient );\n\n      // date format locale?\n      writeString( outputStream, dateFormatLocale != null ? dateFormatLocale.toString() : null );\n\n      // date time zone?\n      writeString( outputStream, dateFormatTimeZone != null ? dateFormatTimeZone.getID() : null );\n\n      // string to number conversion lenient?\n      outputStream.writeBoolean( lenientStringToNumber );\n    } catch ( IOException e ) {\n      throw new KettleFileException( toString() + \" : Unable to write value metadata to output stream\", e );\n    }\n  }\n\n  /**\n   * Load the attributes of this particular value meta object from the input stream. Loading the type is not handled\n   * here, this should be read from the stream previously!\n   *\n   * @param inputStream\n   *          the input stream to read from\n   * @throws KettleFileException\n   *           In case there was a IO problem\n   * @throws KettleEOFException\n   *           If we reached the end of the stream\n   */\n  @Override\n  public void readMetaData( DataInputStream inputStream ) throws KettleFileException, KettleEOFException {\n\n    // Loading the type is not handled here, this should be read from the stream previously!","sourceCodeStart":3071,"sourceCodeEnd":3107,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L3071-L3107","documentation":"ValueMetaBase.writeMetaData serializes this value metadata object's attributes to a DataOutputStream. If any underlying stream write throws an IOException, it is wrapped in a KettleFileException with this message, prefixed by the value meta's name. It means the metadata could not be persisted to the stream, almost always due to an I/O problem or a closed stream, not a bad data type.","triggerScenarios":"Calling writeMetaData(DataOutputStream) when the underlying stream is closed, the socket/file backing it has failed mid-write, or disk is full. Any IOException inside the long block of writeString/writeBoolean calls (e.g. writing name, comments, format masks, timezone ID) triggers it.","commonSituations":"Transrowing metadata between transformations over a network stream that dropped; writing row metadata to a file on a full filesystem; serializing metadata inside a stopped/aborted step whose stream was already closed; a partially-written .ktr/.kwb artifact cache.","solutions":["Check the cause (KettleFileException.getCause()) for the real IOException; fix the underlying stream (closed connection, full disk, broken socket).","Ensure the DataOutputStream is open and flushed before calling writeMetaData and that both writer and reader sides use compatible stream lifecycles.","Verify enough disk space and write permissions for the target file when serializing to disk.","Keep Pentaho/Kettle versions in sync on both ends of the stream so the metadata serialization format matches."],"exampleFix":"// before: writing to a stream that may already be closed\nrowMeta.writeMetaData(outputStream);\n// after: guard the stream state and close in finally\nif (outputStream != null) {\n  try {\n    rowMeta.writeMetaData(outputStream);\n    outputStream.flush();\n  } catch (KettleFileException e) {\n    throw new KettleException(\"Failed to write row metadata\", e);\n  }\n}","handlingStrategy":"try-catch","validationCode":"if (outputStream == null || outputStream.checkError()) throw new IllegalStateException(\"Stream not writable\");\nFile target = new File(path);\nif (target.getUsableSpace() < 1024 * 1024) throw new IllegalStateException(\"Low disk space\");","typeGuard":null,"tryCatchPattern":"try {\n  valueMeta.writeMetaData(dataOutputStream);\n  dataOutputStream.flush();\n} catch (KettleFileException e) {\n  Throwable root = e.getCause();\n  logError(\"Metadata write failed: \" + (root != null ? root.getMessage() : e.getMessage()), e);\n  throw new KettleException(\"Metadata write failed\", e);\n}","preventionTips":["Always wrap stream writes in try-with-resources so streams are closed in a defined order and never written after close.","Check disk space and connection health before large metadata transfers.","Keep Kettle versions identical on both ends of any metadata stream."],"tags":["io","serialization","metadata","kettle"],"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"}