{"record":{"id":"962fe74967465cbe","repo":"pentaho/pentaho-kettle","slug":"mailconnection-error-createfolder","errorCode":null,"errorMessage":"MailConnection.Error.CreateFolder","messagePattern":"MailConnection\\.Error\\.CreateFolder","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/email-messages/impl/src/main/java/org/pentaho/di/job/entries/getpop/MailConnection.java","lineNumber":1114,"sourceCode":"        return;\n      }\n\n      this.destinationIMAPFolder = getOrCreateImapDestinationFolder( foldername, createFolder );\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, ERROR_SET_DESTINATION, foldername ), e );\n    }\n  }\n\n  private String prepareMboxDestinationPath( String foldername, boolean createFolder ) throws KettleException {\n    String resolvedPath = resolveMboxFolderPath( foldername );\n    File destinationFile = new File( resolvedPath );\n    File parentDirectory = destinationFile.getParentFile();\n    if ( parentDirectory == null ) {\n      return resolvedPath;\n    }\n\n    if ( parentDirectory.exists() && !parentDirectory.isDirectory() ) {\n      throw new KettleException( BaseMessages.getString( PKG, ERROR_CREATE_FOLDER, resolvedPath ) );\n    }\n    if ( !parentDirectory.exists() ) {\n      if ( !createFolder ) {\n        throw new KettleException( BaseMessages.getString( PKG, ERROR_FOLDER_NOT_FOUND, foldername ) );\n      }\n      if ( !parentDirectory.mkdirs() ) {\n        throw new KettleException( BaseMessages.getString( PKG, ERROR_CREATE_FOLDER, resolvedPath ) );\n      }\n    }\n    return resolvedPath;\n  }\n\n  private Folder getOrCreateImapDestinationFolder( String foldername, boolean createFolder )\n    throws MessagingException, KettleException {\n    String[] folderparts = foldername.split( \"/\" );\n    Folder destinationFolder = this.getStore().getDefaultFolder();\n    for ( String folderPart : folderparts ) {\n      destinationFolder = destinationFolder.getFolder( folderPart );","sourceCodeStart":1096,"sourceCodeEnd":1132,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/email-messages/impl/src/main/java/org/pentaho/di/job/entries/getpop/MailConnection.java#L1096-L1132","documentation":"Thrown from prepareMboxDestinationPath() when the parent directory of the resolved MBOX destination path exists but is a regular file, not a directory. It uses message key MailConnection.Error.CreateFolder with the resolved path. This is a fail-fast validation before attempting any mkdirs or message appends.","triggerScenarios":"Calling setDestinationFolder(foldername, ...) with MBOX protocol where resolveMboxFolderPath(foldername) returns a path whose parent exists as a plain file — e.g. configured destination '/data/mail/INBOX/2024' while '/data/mail/INBOX' is a file.","commonSituations":"Destination path misconfigured so a parent component collides with an existing file; an earlier run created a file where a directory was expected; symlink pointing at a file.","solutions":["Remove or rename the file that occupies the parent path so a directory can exist there.","Correct the destination folder path in the job entry configuration so no parent component is a file.","Verify with ls/file which path component is the offending file."],"exampleFix":"// before (config)\nDestination folder = /data/mail/archive  // /data/mail is a FILE\n// after\nmv /data/mail /data/mail.bak && mkdir -p /data/mail/archive","handlingStrategy":"validation","validationCode":"File f = new File(resolvedPath);\nif (f.getParentFile() != null && f.getParentFile().exists() && !f.getParentFile().isDirectory()) { throw new IllegalArgumentException(\"Parent path exists but is not a directory: \" + f.getParent()); }","typeGuard":null,"tryCatchPattern":"try { connection.setDestinationFolder(path, true); } catch (KettleException e) { logError(\"Invalid MBOX destination: \" + e.getMessage(), e); }","preventionTips":["Check the destination path parent is a directory with new File(p).getParentFile().isDirectory()","Avoid reusing a path that was previously written as a file","Verify symlinks resolve to directories"],"tags":["mbox","filesystem","path-validation"],"backgroundTag":"path-is-not-a-directory","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"}