{"record":{"id":"31bc5689a737992e","repo":"pentaho/pentaho-kettle","slug":"exporting-transformation-couldn-t-create-file-filename","errorCode":null,"errorMessage":"Exporting transformation: Couldn't create file [${filename}]","messagePattern":"Exporting transformation: Couldn't create file \\[(.+?)\\]","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"ui/src/main/java/org/pentaho/di/ui/repository/dialog/RepositoryExplorerDialog.java","lineNumber":2629,"sourceCode":"\n          for ( int i = 0; i < trans.length; i++ ) {\n            TransMeta ti = rep.loadTransformation( trans[i], repdir, null, true, null ); // reads last version\n            if ( log.isBasic() ) {\n              log.logBasic(\n                \"Exporting transformation\", \"[\" + trans[i] + \"] in directory [\" + repdir.getPath() + \"]\" );\n            }\n\n            String xml = XMLHandler.getXMLHeader() + ti.getXML();\n\n            String filename =\n              directory + repdir.getPath() + Const.FILE_SEPARATOR + fixFileName( trans[i] ) + \".ktr\";\n            File f = new File( filename );\n            try {\n              FileOutputStream fos = new FileOutputStream( f );\n              fos.write( xml.getBytes( Const.XML_ENCODING ) );\n              fos.close();\n            } catch ( IOException e ) {\n              throw new RuntimeException( \"Exporting transformation: Couldn't create file [\" + filename + \"]\", e );\n            }\n          }\n        }\n      }\n    } catch ( Exception e ) {\n      new ErrorDialog( shell,\n        BaseMessages.getString( PKG, \"RepositoryExplorerDialog.ExportTrans.UnexpectedError.Title\" ),\n        BaseMessages.getString( PKG, \"RepositoryExplorerDialog.ExportTrans.UnexpectedError.Message\" ), e );\n    }\n\n  }\n\n  private String fixFileName( String filename ) {\n    filename = filename.replace( '/', '_' ); // do something with illegal file name chars\n    if ( !( \"/\".equals( Const.FILE_SEPARATOR ) ) ) {\n      filename = Const.replace( filename, Const.FILE_SEPARATOR, \"_\" );\n    }\n    return filename;","sourceCodeStart":2611,"sourceCodeEnd":2647,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/ui/src/main/java/org/pentaho/di/ui/repository/dialog/RepositoryExplorerDialog.java#L2611-L2647","documentation":"When exporting a transformation from the repository explorer, the XML is written to a file via FileOutputStream. If an IOException occurs while creating or writing the file, a RuntimeException 'Exporting transformation: Couldn't create file [filename]' is thrown with the IOException as cause. It indicates the target path could not be created or written.","triggerScenarios":"Exporting a transformation to a filename whose parent directory does not exist, the path is a directory, the disk is full, or the process lacks write permission on the path.","commonSituations":"Exporting to a read-only directory or another user's folder; unresolved ${filename} variable or invalid path characters; network drive unavailable; antivirus locking the target file.","solutions":["Verify the export directory exists and is writable before exporting (File.canWrite(), mkdirs)","Check the filename/path for unresolved variables or invalid characters","Run Pentaho/PDI with permissions to write to the target location, or choose a writable directory (e.g. user home)","Inspect the wrapped IOException cause for the underlying OS error"],"exampleFix":"// before\nString filename = \"${output}/trans.ktr\"; // variable not resolved\n// after\nString filename = Variables.getFilename(); // resolved, existing writable path\nFiles.createDirectories(Paths.get(filename).getParent());","handlingStrategy":"validation","validationCode":"File f = new File(filename);\nif (!f.getParentFile().exists()) f.getParentFile().mkdirs();\nif (!f.getParentFile().canWrite()) throw new IllegalStateException(\"Not writable: \" + f.getParent());","typeGuard":null,"tryCatchPattern":"try { exportTransformation(filename); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Exporting transformation\")) { showError(\"Check path/permissions: \" + filename + \" cause: \" + e.getCause()); } else { throw e; } }","preventionTips":["Resolve all ${variables} in the filename before export","Pre-create the target directory and test writability with File.canWrite()","Avoid exporting to network shares or read-only locations","Always inspect the wrapped IOException cause for the exact OS reason"],"tags":["io","file-write","export","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"}