{"record":{"id":"7330c1c990113b78","repo":"pentaho/pentaho-kettle","slug":"unable-to-verify-if-the-job-with-name-name-in-directory","errorCode":null,"errorMessage":"Unable to verify if the job with name [name] in directory [repositoryDirectory] exists","messagePattern":"Unable to verify if the job with name \\[name\\] in directory \\[repositoryDirectory\\] exists","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryJobDelegate.java","lineNumber":282,"sourceCode":"   *\n   * @throws KettleException\n   *           Upon any error.\n   */\n  private void saveJobParameters( JobMeta jobMeta ) throws KettleException {\n    String[] paramKeys = jobMeta.listParameters();\n    for ( int idx = 0; idx < paramKeys.length; idx++ ) {\n      String desc = jobMeta.getParameterDescription( paramKeys[idx] );\n      String defValue = jobMeta.getParameterDefault( paramKeys[idx] );\n      insertJobParameter( jobMeta.getObjectId(), idx, paramKeys[idx], defValue, desc );\n    }\n  }\n\n  public boolean existsJobMeta( String name, RepositoryDirectoryInterface repositoryDirectory,\n    RepositoryObjectType objectType ) throws KettleException {\n    try {\n      return ( getJobID( name, repositoryDirectory.getObjectId() ) != null );\n    } catch ( KettleException e ) {\n      throw new KettleException( \"Unable to verify if the job with name [\"\n        + name + \"] in directory [\" + repositoryDirectory + \"] exists\", e );\n    }\n  }\n\n  /**\n   * Load a job from the repository\n   *\n   * @param jobname\n   *          The name of the job\n   * @param repdir\n   *          The directory in which the job resides.\n   * @throws KettleException\n   */\n  public JobMeta loadJobMeta( String jobname, RepositoryDirectoryInterface repdir ) throws KettleException {\n    return loadJobMeta( jobname, repdir, null );\n  }\n\n  /**","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryJobDelegate.java#L264-L300","documentation":"Thrown by KettleDatabaseRepositoryJobDelegate.existsJobMeta when the underlying repository lookup (getJobID) fails with a KettleException, so existence of the job could not be verified. It wraps the original cause; the message distinguishes 'could not check' from 'job does not exist'. Callers of repository.exists(jobMeta) hit this when the database connection or metadata query breaks.","triggerScenarios":"Calling repository.exists(jobMeta) (which invokes existsJobMeta) when the underlying database query for r_job fails: DB connection lost, repository tables missing/corrupted, or directory ObjectId is null/invalid (job not yet saved into a valid directory).","commonSituations":"Stale repository connection after a network blip or DB restart; querying existence in a directory object that was never saved (null ObjectId); repository schema missing the r_job table after an incomplete upgrade; wrong repository credentials producing permission failures on select.","solutions":["Check the wrapped cause (e.getCause()) to see the real database error and fix it first (connectivity, credentials).","Verify the repository connection is alive; reconnect via repository.connect() before retrying the existence check.","Ensure the RepositoryDirectory was loaded from the repository (not constructed in-memory) so its ObjectId is non-null.","Confirm the repository schema is up to date (run the repository creation/upgrade scripts so r_job exists)."],"exampleFix":"// before: checking existence on an unsaved, in-memory directory\nRepositoryDirectory dir = new RepositoryDirectory();\nboolean exists = repo.exists(\"MyJob\", dir, RepositoryObjectType.JOB);\n\n// after: load the directory from the repository first\nRepositoryDirectory dir = repo.loadRepositoryDirectoryTree().findDirectory(\"/jobs\");\nboolean exists = repo.exists(\"MyJob\", dir, RepositoryObjectType.JOB);","handlingStrategy":"try-catch","validationCode":"// pre-flight check\nif (repo == null || !repo.isConnected()) throw new IllegalStateException(\"Repository not connected\");\nif (name == null || name.isEmpty()) throw new IllegalArgumentException(\"Job name required\");\nif (directory == null || directory.getObjectId() == null) throw new IllegalArgumentException(\"Directory must be loaded from repository (non-null ObjectId)\");","typeGuard":"boolean isUsableDirectory(RepositoryDirectoryInterface d) {\n  return d != null && d.getObjectId() != null;\n}","tryCatchPattern":"try {\n  exists = repo.exists(\"MyJob\", dir, RepositoryObjectType.JOB);\n} catch (KettleException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  // log root; reconnect and retry if it was a connection failure\n  repo.connect();\n}","preventionTips":["Always load the directory tree from the repository before existence checks (never use a bare new RepositoryDirectory()).","Keep the repository session alive; reconnect after DB restarts or long idle periods.","Keep repository schema version in sync with the Pentaho client version.","Log e.getCause() chains to diagnose the real database problem quickly."],"tags":["database","repository","existence-check","kettle"],"backgroundTag":"database-query-failed","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"}