pentaho/pentaho-kettle · error · KettleException

Unable to limit dirs because importer

Error message

Unable to limit dirs because importer {0} doesn't support it

What it means

Import.main throws KettleException "Unable to limit dirs because importer {0} doesn't support it" when directory limits (-limit-dir) were requested but the repository's IRepositoryImporter does not implement the CanLimitDirs interface. The message is parameterized with the importer class name. It is a capability mismatch between the requested CLI option and the importer implementation.

Solutions

  1. Remove the -limit-dir options and restrict the file selection before import instead.
  2. Use a repository whose importer implements CanLimitDirs.
  3. Implement CanLimitDirs (setLimitDirs) in your custom importer plugin.
  4. Check importer.getClass().getCanonicalName() in the message to identify the lacking implementation.

Example fix

// before
importer.setImportRules(importRules);
((CanLimitDirs) importer).setLimitDirs(limitDirs); // assumes support
// after
importer.setImportRules(importRules);
if (importer instanceof CanLimitDirs) {
  ((CanLimitDirs) importer).setLimitDirs(limitDirs);
} else {
  log.logError("Importer does not support limiting dirs; skipping limit");
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (!limitDirs.isEmpty() && !(repository.getImporter() instanceof CanLimitDirs)) {
  throw new IllegalArgumentException("This importer cannot limit directories; drop -limit-dir options");
}

Type guard

if (importer instanceof CanLimitDirs) {
  ((CanLimitDirs) importer).setLimitDirs(limitDirs);
}

Try / catch

try {
  Import.main(args);
} catch (KettleException e) {
  if (e.getMessage() != null && e.getMessage().contains("limit dirs")) {
    log.error("Remove -limit-dir or switch to a repository importer implementing CanLimitDirs");
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Running the import command with a non-empty limitDirs list while repository.getImporter() returns an importer that is not an instanceof CanLimitDirs.

Common situations: Using a custom or alternative repository importer plugin that never implemented CanLimitDirs; passing -limit-dir options against a repository type whose importer lacks directory-limiting support.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/imp/Import.java:365

    int returnCode = 0;
    try {
      RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();

      RepositoryDirectoryInterface targetDirectory = tree.findDirectory( optionDirname.toString() );
      if ( targetDirectory == null ) {
        log.logError( BaseMessages.getString(
          PKG, "Import.Error.UnableToFindTargetDirectoryInRepository", optionDirname.toString() ) );
        exitJVM( 1 );
      }

      // Perform the actual import
      IRepositoryImporter importer = repository.getImporter();
      importer.setImportRules( importRules );
      if ( !limitDirs.isEmpty() ) {
        if ( importer instanceof CanLimitDirs ) {
          ( (CanLimitDirs) importer ).setLimitDirs( limitDirs );
        } else {
          throw new KettleException( BaseMessages.getString( PKG, "Import.CouldntLimitDirs", importer.getClass()
              .getCanonicalName() ) );
        }
      }
      RepositoryImportFeedbackInterface feedbackInterface = new ImportFeedback( log, continueOnError, replace, reader );

      // Import files in a certain directory
      importer.importAll( feedbackInterface, optionFileDir.toString(), filenames.toArray( new String[filenames
        .size()] ), targetDirectory, replace, continueOnError, optionComment.toString() );

      // If the importer has exceptions, then our return code is 2
      List<Exception> exceptions = importer.getExceptions();
      if ( exceptions != null && !exceptions.isEmpty() ) {
        log.logError( BaseMessages.getString( PKG, "Import.Error.UnexpectedErrorDuringImport" ), exceptions
          .get( 0 ) );
        returnCode = 2;
      }
    } catch ( Exception e ) {
      log.logError( BaseMessages.getString( PKG, "Import.Error.UnexpectedErrorDuringImport" ), e );

View on GitHub (pinned to f3058517a1)