{"record":{"id":"a3a22eeb67069d32","repo":"pentaho/pentaho-kettle","slug":"zipfile-error-targetparentfoldernotexists","errorCode":null,"errorMessage":"ZipFile.Error.TargetParentFolderNotExists","messagePattern":"ZipFile\\.Error\\.TargetParentFolderNotExists","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/zipfile/ZipFile.java","lineNumber":203,"sourceCode":"\n        if ( Utils.isEmpty( targetFilename ) ) {\n          log.logError( toString(), BaseMessages.getString( PKG, \"ZipFile.Error.TargetFileEmpty\" ) );\n          throw new KettleException( BaseMessages.getString( PKG, \"ZipFile.Error.TargetFileEmpty\" ) );\n        }\n        data.zipFile = KettleVFS.getInstance( getTransMeta().getBowl() ).getFileObject( targetFilename, this );\n        if ( data.zipFile.exists() ) {\n          if ( log.isDetailed() ) {\n            log.logDetailed( toString(), BaseMessages.getString(\n              PKG, \"ZipFile.Log.TargetFileExists\", targetFilename ) );\n          }\n        } else {\n          // let's check parent folder\n          FileObject parentFolder = data.zipFile.getParent();\n          if ( !parentFolder.exists() ) {\n            if ( !meta.isCreateParentFolder() ) {\n              // Parent folder not exist\n              // So we will fail\n              throw new KettleException( BaseMessages.getString(\n                PKG, \"ZipFile.Error.TargetParentFolderNotExists\", parentFolder.toString() ) );\n            } else {\n              // Create parent folder\n              parentFolder.createFolder();\n            }\n          }\n          if ( parentFolder != null ) {\n            parentFolder.close();\n          }\n        }\n\n        // Let's zip\n        zipFile();\n\n        // file was zipped, let's see if we need to move or delete it\n        processFile( moveToFolder );\n\n        // add filename to result filenames?","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/zipfile/ZipFile.java#L185-L221","documentation":"The zip target file's parent folder does not exist and the 'create parent folder' option is disabled, so the step fails instead of silently creating directories. This protects users from accidentally creating unintended directory trees when the target path is wrong.","triggerScenarios":"data.zipFile.getParent().exists() is false and meta.isCreateParentFolder() is false at ZipFile.java:203; thrown before writing the archive.","commonSituations":"Target path includes a new subdirectory that was never created (e.g., per-date folders like /out/2026/09/); typo in the target path so an unintended nonexistent folder is referenced; running on a fresh environment where the output tree was not provisioned; permissions prevented an earlier mkdir.","solutions":["Enable 'Create parent folder' in the ZipFile step settings so missing directories are created automatically.","Create the target directory in advance with a 'Create a folder' step or shell script.","Verify the target filename/path is correct if the missing folder is unexpected.","Check filesystem permissions if folder creation is expected to have happened."],"exampleFix":"// before\nmeta.setCreateParentFolder(false);\n// after\nmeta.setCreateParentFolder(true);","handlingStrategy":"validation","validationCode":"// Before execution, ensure the target directory exists or auto-create is enabled\nif (!zipFileMeta.isCreateParentFolder()) {\n  File parent = new File(targetFilename).getParentFile();\n  if (parent != null && !parent.exists()) {\n    parent.mkdirs(); // or fail fast with a clear message\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  transformation.execute();\n} catch (KettleException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"TargetParentFolderNotExists\")) {\n    log.error(\"ZipFile target parent folder missing: enable 'create parent folder' or mkdir first\", e);\n  } else { throw e; }\n}","preventionTips":["Enable 'Create parent folder' when writing to dynamic/nested output paths.","Provision output directory trees in environment setup scripts.","Verify permissions allow folder creation on the target filesystem.","Sanity-check target paths with date-based subfolders before production runs."],"tags":["pdi","kettle","filesystem","zip","directory"],"backgroundTag":"directory-not-found","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"}