{"record":{"id":"491efe142a7b619f","repo":"pentaho/pentaho-kettle","slug":"the-element-to-update-with-id-elementid-could-not-be-found","errorCode":null,"errorMessage":"The element to update with id ${elementId} could not be found in the store","messagePattern":"The element to update with id (.+?) could not be found in the store","errorType":"exception","errorClass":"MetaStoreException","httpStatus":null,"severity":"error","filePath":"plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/metastore/PurRepositoryMetaStore.java","lineNumber":341,"sourceCode":"\n  @Override\n  public synchronized void updateElement( String namespace, IMetaStoreElementType elementType, String elementId,\n      IMetaStoreElement element ) throws MetaStoreException {\n\n    // verify that the element type belongs to this meta store\n    //\n    if ( elementType.getMetaStoreName() == null || !elementType.getName().equals( getName() ) ) {\n      String elementTypeName = elementType.getName();\n      elementType = getElementTypeByName( namespace, elementTypeName );\n      if ( elementType == null ) {\n        throw new MetaStoreException( \"The element type '\" + elementTypeName\n            + \"' could not be found in the meta store in which you are updating.\" );\n      }\n    }\n\n    RepositoryFile existingFile = pur.getFileById( elementId );\n    if ( existingFile == null ) {\n      throw new MetaStoreException( \"The element to update with id \" + elementId + \" could not be found in the store\" );\n    }\n\n    DataNode elementDataNode = new DataNode( PurRepository.checkAndSanitize( element.getName() ) );\n    elementToDataNode( element, elementDataNode );\n\n    RepositoryFile updatedFile = pur.updateFile( existingFile, new NodeRepositoryFileData( elementDataNode ), null );\n    element.setId( updatedFile.getId().toString() );\n  }\n\n  @Override\n  public IMetaStoreElement getElement( String namespace, IMetaStoreElementType elementType, String elementId )\n    throws MetaStoreException {\n    NodeRepositoryFileData data = pur.getDataForRead( elementId, NodeRepositoryFileData.class );\n    if ( data == null ) {\n      return null;\n    }\n\n    IMetaStoreElement element = newElement();","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/pur/core/src/main/java/org/pentaho/di/repository/pur/metastore/PurRepositoryMetaStore.java#L323-L359","documentation":"updateElement fetches the underlying repository file for the element by its elementId. If pur.getFileById(elementId) returns null, no element with that id exists in the PUR repository, so there is nothing to update and a MetaStoreException is thrown. This protects against updating nonexistent or already-deleted elements.","triggerScenarios":"Calling updateElement with an elementId that does not correspond to any existing repository file — typically a stale id from a deleted element or an id from a different repository.","commonSituations":"Another user/session deleted or moved the element between listing and updating; caching an elementId across repository connections; pointing at a different repository than where the element was created.","solutions":["Re-fetch the element by name via getElementById/getElementsByElementType to obtain a current, valid elementId before updating.","Check that the element still exists (getElementById(elementId) != null) before calling updateElement.","Confirm you are connected to the same repository where the element was created.","Handle the delete-then-update race by catching the exception and refreshing the element list."],"exampleFix":"// before\nmetaStore.updateElement(namespace, elementType, elementId, element);\n// after\nIMetaStoreElement existing = metaStore.getElementById(namespace, elementType, elementId);\nif (existing != null) {\n  metaStore.updateElement(namespace, elementType, elementId, element);\n}","handlingStrategy":"validation","validationCode":"if (metaStore.getElementById(namespace, elementType, elementId) == null) {\n  throw new IllegalStateException(\"Element \" + elementId + \" no longer exists\");\n}","typeGuard":null,"tryCatchPattern":"try { metaStore.updateElement(...); }\ncatch (MetaStoreException e) { refreshElementList(); /* handle deleted element */ }","preventionTips":["Re-fetch element ids right before updating","Don't persist elementIds across sessions or repositories"],"tags":["metastore","repository","pentaho","stale-id"],"backgroundTag":"record-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"}