{"record":{"id":"c8a4f4b9e00fc1d4","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-lock-for-object-with-id-id","errorCode":null,"errorMessage":"Unable to get lock for object with id [${id}]","messagePattern":"Unable to get lock for object with id \\[(.+?)\\]","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/UnifiedRepositoryLockService.java","lineNumber":49,"sourceCode":"  protected void lockFileById( final ObjectId id, final String message ) throws KettleException {\n    pur.lockFile( id.getId(), message );\n  }\n\n  public RepositoryLock getLock( final RepositoryFile file ) throws KettleException {\n    if ( file.isLocked() ) {\n      return new RepositoryLock( new StringObjectId( file.getId().toString() ), file.getLockMessage(), file\n          .getLockOwner(), file.getLockOwner(), file.getLockDate() );\n    } else {\n      return null;\n    }\n  }\n\n  protected RepositoryLock getLockById( final ObjectId id ) throws KettleException {\n    try {\n      RepositoryFile file = pur.getFileById( id.getId() );\n      return getLock( file );\n    } catch ( Exception e ) {\n      throw new KettleException( \"Unable to get lock for object with id [\" + id + \"]\", e );\n    }\n  }\n\n  protected void unlockFileById( ObjectId id ) throws KettleException {\n    pur.unlockFile( id.getId() );\n  }\n\n  @Override\n  public RepositoryLock lockJob( final ObjectId idJob, final String message ) throws KettleException {\n    lockFileById( idJob, message );\n    return getLockById( idJob );\n  }\n\n  @Override\n  public void unlockJob( ObjectId idJob ) throws KettleException {\n    unlockFileById( idJob );\n  }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/UnifiedRepositoryLockService.java#L31-L67","documentation":"UnifiedRepositoryLockService.getLockById fetches the RepositoryFile by ID and extracts its lock information. Any exception from the underlying repository call (file not found, access denied, connectivity) is wrapped in this KettleException. It means the lock state for the given object could not be determined or obtained.","triggerScenarios":"Calling lockJob, getJobLock, lockTransformation, or getTransformationLock with an ObjectId that does not exist in the repository, or when pur.getFileById fails for any reason (permissions, network, server error).","commonSituations":"Checking locks for objects deleted by another user, stale IDs from a previous repository instance, network/server outages during lock checks, or insufficient read permissions on the file.","solutions":["Verify the ObjectId refers to an existing repository file (check the wrapped cause via getCause()).","Re-fetch the object to get a fresh ObjectId if the repository was re-imported or the file re-created.","Check the user has read access to the file in question.","Check server connectivity; if the cause is a network/auth error, reconnect and retry."],"exampleFix":"// before\nRepositoryLock lock = lockService.getTransformationLock( transMeta.getObjectId() ); // may throw\n// after\ntry {\n  RepositoryLock lock = lockService.getTransformationLock( transMeta.getObjectId() );\n} catch ( KettleException e ) {\n  if ( pur.getFileById( transMeta.getObjectId().getId() ) == null ) {\n    log.logBasic( \"Object no longer exists; skipping lock check\" );\n  } else {\n    throw e;\n  }\n}","handlingStrategy":"try-catch","validationCode":"boolean lockable( UnifiedRepositoryConnection pur, ObjectId id ) {\n  try { return pur.getFileById( id.getId() ) != null; } catch ( Exception e ) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  RepositoryLock lock = lockService.getJobLock( jobId );\n} catch ( KettleException e ) {\n  logError( \"Lock lookup failed for id \" + jobId + \": \" + e.getCause() );\n  // fall back to treating object as unlocked only if cause is not-found\n}","preventionTips":["Verify object IDs are fresh (re-fetch after repository changes)","Check user read permissions on files before lock operations","Handle deleted objects gracefully in automation","Reconnect on network/auth causes before retrying"],"tags":["locking","repository","pentaho-kettle"],"backgroundTag":"resource-not-found","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"}