{"record":{"id":"dd5cad92b1549cae","repo":"pentaho/pentaho-kettle","slug":"unable-to-limit-dirs-because-importer-0-doesn-t-support-it","errorCode":null,"errorMessage":"Unable to limit dirs because importer {0} doesn't support it","messagePattern":"Unable to limit dirs because importer (.+?) doesn't support it","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/imp/Import.java","lineNumber":365,"sourceCode":"    int returnCode = 0;\n    try {\n      RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();\n\n      RepositoryDirectoryInterface targetDirectory = tree.findDirectory( optionDirname.toString() );\n      if ( targetDirectory == null ) {\n        log.logError( BaseMessages.getString(\n          PKG, \"Import.Error.UnableToFindTargetDirectoryInRepository\", optionDirname.toString() ) );\n        exitJVM( 1 );\n      }\n\n      // Perform the actual import\n      IRepositoryImporter importer = repository.getImporter();\n      importer.setImportRules( importRules );\n      if ( !limitDirs.isEmpty() ) {\n        if ( importer instanceof CanLimitDirs ) {\n          ( (CanLimitDirs) importer ).setLimitDirs( limitDirs );\n        } else {\n          throw new KettleException( BaseMessages.getString( PKG, \"Import.CouldntLimitDirs\", importer.getClass()\n              .getCanonicalName() ) );\n        }\n      }\n      RepositoryImportFeedbackInterface feedbackInterface = new ImportFeedback( log, continueOnError, replace, reader );\n\n      // Import files in a certain directory\n      importer.importAll( feedbackInterface, optionFileDir.toString(), filenames.toArray( new String[filenames\n        .size()] ), targetDirectory, replace, continueOnError, optionComment.toString() );\n\n      // If the importer has exceptions, then our return code is 2\n      List<Exception> exceptions = importer.getExceptions();\n      if ( exceptions != null && !exceptions.isEmpty() ) {\n        log.logError( BaseMessages.getString( PKG, \"Import.Error.UnexpectedErrorDuringImport\" ), exceptions\n          .get( 0 ) );\n        returnCode = 2;\n      }\n    } catch ( Exception e ) {\n      log.logError( BaseMessages.getString( PKG, \"Import.Error.UnexpectedErrorDuringImport\" ), e );","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/imp/Import.java#L347-L383","documentation":"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.","triggerScenarios":"Running the import command with a non-empty limitDirs list while repository.getImporter() returns an importer that is not an instanceof CanLimitDirs.","commonSituations":"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.","solutions":["Remove the -limit-dir options and restrict the file selection before import instead.","Use a repository whose importer implements CanLimitDirs.","Implement CanLimitDirs (setLimitDirs) in your custom importer plugin.","Check importer.getClass().getCanonicalName() in the message to identify the lacking implementation."],"exampleFix":"// before\nimporter.setImportRules(importRules);\n((CanLimitDirs) importer).setLimitDirs(limitDirs); // assumes support\n// after\nimporter.setImportRules(importRules);\nif (importer instanceof CanLimitDirs) {\n  ((CanLimitDirs) importer).setLimitDirs(limitDirs);\n} else {\n  log.logError(\"Importer does not support limiting dirs; skipping limit\");\n}","handlingStrategy":"type-guard","validationCode":"if (!limitDirs.isEmpty() && !(repository.getImporter() instanceof CanLimitDirs)) {\n  throw new IllegalArgumentException(\"This importer cannot limit directories; drop -limit-dir options\");\n}","typeGuard":"if (importer instanceof CanLimitDirs) {\n  ((CanLimitDirs) importer).setLimitDirs(limitDirs);\n}","tryCatchPattern":"try {\n  Import.main(args);\n} catch (KettleException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"limit dirs\")) {\n    log.error(\"Remove -limit-dir or switch to a repository importer implementing CanLimitDirs\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Check importer capabilities before passing -limit-dir","Pre-filter the file list instead of relying on directory limiting","Document importer plugin capability requirements"],"tags":["unsupported-operation","cli","repository-import"],"backgroundTag":"unsupported-operation","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"}