pentaho/pentaho-kettle · error · KettleException

MailConnection.Error.CreateFolder

Error message

MailConnection.Error.CreateFolder

What it means

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.

Solutions

  1. Remove or rename the file that occupies the parent path so a directory can exist there.
  2. Correct the destination folder path in the job entry configuration so no parent component is a file.
  3. Verify with ls/file which path component is the offending file.

Example fix

// before (config)
Destination folder = /data/mail/archive  // /data/mail is a FILE
// after
mv /data/mail /data/mail.bak && mkdir -p /data/mail/archive
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(resolvedPath);
if (f.getParentFile() != null && f.getParentFile().exists() && !f.getParentFile().isDirectory()) { throw new IllegalArgumentException("Parent path exists but is not a directory: " + f.getParent()); }

Try / catch

try { connection.setDestinationFolder(path, true); } catch (KettleException e) { logError("Invalid MBOX destination: " + e.getMessage(), e); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/962fe74967465cbe. Report an issue: GitHub.

Appendix: source

Thrown at plugins/email-messages/impl/src/main/java/org/pentaho/di/job/entries/getpop/MailConnection.java:1114

        return;
      }

      this.destinationIMAPFolder = getOrCreateImapDestinationFolder( foldername, createFolder );
    } catch ( Exception e ) {
      throw new KettleException( BaseMessages.getString( PKG, ERROR_SET_DESTINATION, foldername ), e );
    }
  }

  private String prepareMboxDestinationPath( String foldername, boolean createFolder ) throws KettleException {
    String resolvedPath = resolveMboxFolderPath( foldername );
    File destinationFile = new File( resolvedPath );
    File parentDirectory = destinationFile.getParentFile();
    if ( parentDirectory == null ) {
      return resolvedPath;
    }

    if ( parentDirectory.exists() && !parentDirectory.isDirectory() ) {
      throw new KettleException( BaseMessages.getString( PKG, ERROR_CREATE_FOLDER, resolvedPath ) );
    }
    if ( !parentDirectory.exists() ) {
      if ( !createFolder ) {
        throw new KettleException( BaseMessages.getString( PKG, ERROR_FOLDER_NOT_FOUND, foldername ) );
      }
      if ( !parentDirectory.mkdirs() ) {
        throw new KettleException( BaseMessages.getString( PKG, ERROR_CREATE_FOLDER, resolvedPath ) );
      }
    }
    return resolvedPath;
  }

  private Folder getOrCreateImapDestinationFolder( String foldername, boolean createFolder )
    throws MessagingException, KettleException {
    String[] folderparts = foldername.split( "/" );
    Folder destinationFolder = this.getStore().getDefaultFolder();
    for ( String folderPart : folderparts ) {
      destinationFolder = destinationFolder.getFolder( folderPart );

View on GitHub (pinned to f3058517a1)