{"record":{"id":"cf11e27cf1ec4e04","repo":"pentaho/pentaho-kettle","slug":"zipfile-errorcreatingzip","errorCode":null,"errorMessage":"ZipFile.ErrorCreatingZip","messagePattern":"ZipFile\\.ErrorCreatingZip","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/zipfile/ZipFile.java","lineNumber":435,"sourceCode":"        // Get full filename\n        relativeName = KettleVFS.getFilename( data.sourceFile );\n\n        if ( data.baseFolder != null ) {\n          // Remove base folder\n          data.baseFolder += Const.FILE_SEPARATOR;\n          relativeName = relativeName.replace( data.baseFolder, \"\" );\n        }\n      }\n      if ( !fileSet.contains( relativeName ) ) {\n        out.putNextEntry( new ZipEntry( relativeName ) );\n\n        int len;\n        while ( ( len = in.read( buffer ) ) > 0 ) {\n          out.write( buffer, 0, len );\n        }\n      }\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"ZipFile.ErrorCreatingZip\" ), e );\n    } finally {\n      try {\n        if ( in != null ) {\n          // Close the current file input stream\n          in.close();\n        }\n        if ( out != null ) {\n          // Close the ZipOutPutStream\n          out.flush();\n          out.closeEntry();\n          out.close();\n        }\n        if ( buff != null ) {\n          buff.close();\n        }\n        if ( dest != null ) {\n          dest.close();\n        }","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/zipfile/ZipFile.java#L417-L453","documentation":"The ZipFile step wraps any Exception raised while streaming a source file into the zip output as this KettleException, from the read/write loop in zipFile(). It indicates the zip archive could not be created or completed — usually an unreadable source file, a missing parent directory for the target zip, or an I/O failure mid-write.","triggerScenarios":"zipFile() throws while in.read fails (source file unreadable/deleted), out.write fails (disk full, target zip path in non-existent directory, permissions), or the ZipOutputStream itself errors during create/close.","commonSituations":"Source file removed by another process between listing and zipping; output folder deleted at runtime; insufficient disk space; permission denied on the target zip path; concurrent runs writing the same zip file.","solutions":["Read the chained cause 'e' — it names the actual I/O problem (FileNotFoundException, disk full, etc.).","Verify the output zip's parent directory exists and is writable before running the step.","Verify all source files listed are readable at the moment the step runs (permissions, not locked/deleted).","Check free disk space on the volume holding the target zip.","Avoid concurrent steps writing to the same zip file."],"exampleFix":"// before: output dir does not exist -> out.write fails\nString zipFile = \"/data/out/archive.zip\";\n// after: ensure parent dir first\nFiles.createDirectories(Paths.get(\"/data/out\"));\nString zipFile = \"/data/out/archive.zip\";","handlingStrategy":"try-catch","validationCode":"File out = new File(zipPath);\nif (!out.getParentFile().canWrite()) throw new IllegalStateException(\"Cannot write to \" + out.getParent());\nif (!new File(sourcePath).canRead()) throw new IllegalStateException(\"Cannot read source \" + sourcePath);","typeGuard":null,"tryCatchPattern":"try {\n    runTransformation(zipFileTrans);\n} catch (KettleException e) {\n    Throwable cause = e.getCause(); // inspect real I/O cause\n    log.error(\"Zip creation failed: {}\", cause != null ? cause.getMessage() : e.getMessage(), e);\n    throw e;\n}","preventionTips":["Monitor free disk space on the output volume.","Pre-create and verify writability of the output directory.","Avoid concurrent jobs writing the same target zip.","Check source files are readable (not locked by other processes) before zipping."],"tags":["io","zip","filesystem","kettle-step"],"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"}