{"record":{"id":"6bf59fd3b90d62b5","repo":"pentaho/pentaho-kettle","slug":"dirname-is-not-a-directory","errorCode":null,"errorMessage":"'<dirname>' is not a directory","messagePattern":"'<dirname>' is not a directory","errorType":"exception","errorClass":"KettleJobException","httpStatus":null,"severity":"error","filePath":"plugins/dummy/core/src/main/java/org/pentaho/di/pdi/jobentry/dummy/DummyJob.java","lineNumber":76,"sourceCode":"        return false;\n      }\n    };\n    long files = 0;\n    File[] allFiles = srcDir.listFiles( regexFiler );\n    File outDir = new File( _targetDir );\n    outDir.mkdirs();\n    for ( int i = 0; i < allFiles.length; i++ ) {\n      File cFile = allFiles[i];\n      log.logDetailed( toString(), \"processing file '\" + cFile + \"'\" );\n      processFile( cFile, outDir );\n    }\n    return files;\n  }\n\n  public File getDir( String dirname ) throws KettleJobException {\n    File fl = new File( dirname );\n    if ( !fl.isDirectory() ) {\n      throw new KettleJobException( \"'\" + dirname + \"' is not a directory\" );\n    }\n    return fl;\n  }\n\n  public void processFile( File fl, File outDir ) throws FileNotFoundException {\n    // do something with the file here\n\n  }\n}\n","sourceCodeStart":58,"sourceCodeEnd":86,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/dummy/core/src/main/java/org/pentaho/di/pdi/jobentry/dummy/DummyJob.java#L58-L86","documentation":"DummyJob.getDir wraps a java.io.File for the given dirname and throws KettleJobException when File.isDirectory() returns false — i.e. the path does not exist or exists but is a regular file. It is a fail-fast argument validator used by srcDir before scanning a directory of files.","triggerScenarios":"Calling getDir (or srcDir, which calls it) with a dirname that is a file path, a typo'd/non-existent path, an empty string, or a path that exists relative to a different working directory than expected.","commonSituations":"Hard-coded job-entry directory settings pointing to a machine-local path that doesn't exist on the execution node; variable substitution (${Internal.Job.Filename.Directory}) resolving unexpectedly; path moved/renamed between job design and run; running the job from a different working directory so relative paths break.","solutions":["Print/resolve the actual dirname at runtime and verify it exists and is a directory (ls <dirname>).","Fix the job entry configuration to use an absolute path or correct variable expression.","If the path can legitimately be a file or missing, check new File(dirname).isDirectory() before calling and handle it.","Ensure the path is valid on the node that executes the job (agents/cluster nodes may not share the same filesystem)."],"exampleFix":"// before\nFile dir = job.getDir( \"/data/input\" ); // throws if missing\n// after\nFile f = new File( \"/data/input\" );\nif ( !f.isDirectory() ) {\n  throw new KettleJobException( \"Input directory missing: \" + f.getAbsolutePath() );\n}\nFile dir = job.getDir( f.getAbsolutePath() );","handlingStrategy":"validation","validationCode":"// guard before calling getDir/srcDir\nFile f = new File( dirname );\nif ( !f.exists() ) {\n  throw new IllegalArgumentException( \"Directory does not exist: \" + f.getAbsolutePath() );\n}\nif ( !f.isDirectory() ) {\n  throw new IllegalArgumentException( \"Path is a file, not a directory: \" + f.getAbsolutePath() );\n}","typeGuard":null,"tryCatchPattern":"try {\n  File dir = job.getDir( dirname );\n  job.srcDir( dirname, outDir );\n} catch ( KettleJobException e ) {\n  if ( e.getMessage() != null && e.getMessage().endsWith( \"is not a directory\" ) ) {\n    logError( \"Check path config: \" + e.getMessage() );\n    // skip or substitute a default directory\n  } else {\n    throw e;\n  }\n}","preventionTips":["Use absolute paths in job entry configuration, or verified variable substitutions","Validate directory existence on the executing node, not just the design machine","Guard with new File(path).isDirectory() before invoking directory-scanning methods","Watch for working-directory differences that break relative paths"],"tags":["filesystem","io","validation","job"],"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"}