{"record":{"id":"30e2d49fd9906d36","repo":"pentaho/pentaho-kettle","slug":"error-opening-file-data-filename","errorCode":null,"errorMessage":"Error opening file [\" + data.filename + \"]!","messagePattern":"Error opening file \\[\" \\+ data\\.filename \\+ \"\\]!","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/propertyoutput/PropertyOutput.java","lineNumber":186,"sourceCode":"    return data.previousFileName.equals( data.filename );\n  }\n\n  private void openNewFile() throws KettleException {\n    try ( FileObject newFile = KettleVFS.getInstance( getTransMeta().getBowl() )\n          .getFileObject( data.filename, getTransMeta() ) ) {\n      data.pro = new Properties();\n      data.KeySet.clear();\n\n      data.file = newFile;\n      if ( meta.isAppend() && data.file.exists() ) {\n        data.pro.load( KettleVFS.getInputStream( data.file ) );\n      }\n      // Create parent folder if needed...\n      createParentFolder();\n      //save processing file\n      data.previousFileName = data.filename;\n    } catch ( Exception e ) {\n      throw new KettleException( \"Error opening file [\" + data.filename + \"]!\", e );\n    }\n  }\n\n  private void createParentFolder() throws KettleException {\n    if ( meta.isCreateParentFolder() ) {\n      FileObject parentfolder = null;\n      try {\n        // Do we need to create parent folder ?\n\n        // Check for parent folder\n        // Get parent folder\n        parentfolder = data.file.getParent();\n        if ( !parentfolder.exists() ) {\n          if ( log.isDetailed() ) {\n            logDetailed( BaseMessages.getString( PKG, \"PropertyOutput.Log.ParentFolderExists\", parentfolder.getName().toString() ) );\n          }\n          parentfolder.createFolder();\n          if ( log.isDetailed() ) {","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/propertyoutput/PropertyOutput.java#L168-L204","documentation":"openNewFile wraps all file-opening work in a try-catch and rethrows any Exception as a KettleException with message \"Error opening file [<filename>]!\". This is a generic wrapper: the root cause (missing directory, permissions, invalid path, VFS error) is attached as the cause. It fires after the parent folder creation and before/while creating the file via the Kettle VFS layer.","triggerScenarios":"processRow calls openNewFile(); any exception inside (KettleFileException from KettleVFS.getFileObject/createParentFolder/file creation, invalid URI characters in the filename, IO errors) is caught and rethrown with this message.","commonSituations":"Target directory is read-only or the process lacks write permission; filename contains characters invalid for the filesystem or VFS URI; network/SFTP target unreachable; disk full when creating the file.","solutions":["Inspect the chained cause (e.getCause()) to find the real failure; fix permissions on the target directory.","Verify the resolved filename is a valid path for the OS/VFS scheme (watch for unexpanded variables or special characters).","Ensure the parent directory exists or enable 'Create parent folder' in the step settings.","Check disk space and connectivity if the file is on a remote filesystem."],"exampleFix":"// before\nString file = \"${UNSET_VAR}/out.properties\"; // resolves with literal ${UNSET_VAR}\n// after\nString file = \"/data/output/out.properties\"; // or ensure the variable is defined at runtime","handlingStrategy":"try-catch","validationCode":"File f = new File(filename);\nFile parent = f.getAbsoluteFile().getParentFile();\nif (parent != null && !parent.canWrite()) {\n    throw new IllegalStateException(\"No write permission on \" + parent);\n}","typeGuard":null,"tryCatchPattern":"try {\n    openNewFile();\n} catch (KettleException e) {\n    Throwable root = e;\n    while (root.getCause() != null) root = root.getCause();\n    logError(\"Failed to open \" + data.filename + \": \" + root.getMessage());\n}","preventionTips":["Pre-create output directories with correct ownership and permissions.","Avoid special characters and unexpanded variables in output filenames.","Enable 'Create parent folder' so missing directories are handled automatically.","Monitor disk space on output volumes."],"tags":["pentaho-kettle","file-io","vfs","file-open-failed"],"backgroundTag":"file-open-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"}