{"record":{"id":"25b039d5b9de4c2c","repo":"pentaho/pentaho-kettle","slug":"unexpected-error-deleting-an-element-in-the-shared-objects","errorCode":null,"errorMessage":"Unexpected error deleting an element in the shared objects meta store","messagePattern":"Unexpected error deleting an element in the shared objects meta store","errorType":"exception","errorClass":"MetaStoreException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/shared/SharedObjectsMetaStore.java","lineNumber":190,"sourceCode":"      }\n      throw new MetaStoreException( \"Storing elements with element type name '\"\n        + elementType.getName() + \"' is not supported in the shared objects meta store\" );\n    } catch ( Exception e ) {\n      throw new MetaStoreException( \"Unexpected error creating an element in the shared objects meta store\", e );\n    }\n  }\n\n  @Override\n  public void deleteElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException {\n    try {\n      if ( elementType.getName().equals( databaseElementType.getName() ) ) {\n        sharedObjects.removeObject( DatabaseMetaStoreUtil.loadDatabaseMetaFromDatabaseElement( this, getElement(\n          namespace, elementType, elementId ) ) );\n        sharedObjects.saveToFile();\n        return;\n      }\n    } catch ( Exception e ) {\n      throw new MetaStoreException( \"Unexpected error deleting an element in the shared objects meta store\", e );\n    }\n  }\n\n  public SharedObjects getSharedObjects() {\n    return sharedObjects;\n  }\n\n  public void setSharedObjects( SharedObjects sharedObjects ) {\n    this.sharedObjects = sharedObjects;\n  }\n\n}\n","sourceCodeStart":172,"sourceCodeEnd":203,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/shared/SharedObjectsMetaStore.java#L172-L203","documentation":"deleteElement() wraps any exception thrown while removing an element (element lookup, DatabaseMeta conversion via DatabaseMetaStoreUtil, removeObject, or saveToFile) into MetaStoreException with the message 'Unexpected error deleting an element in the shared objects meta store', attaching the original cause.","triggerScenarios":"Calling deleteElement for a database-type element when getElement() cannot find the id, the DatabaseMeta conversion fails, or saveToFile() throws on IO errors (permissions, disk full).","commonSituations":"Deleting a connection that no longer exists in shared.xml; read-only or locked shared.xml; corrupted element data preventing conversion back to DatabaseMeta.","solutions":["Confirm the element id exists via getElement()/getElementByName() before deleting","Check the shared objects file is writable and uncorrupted","Inspect e.getCause() to identify the underlying lookup or IO failure"],"exampleFix":"// before\nmetaStore.deleteElement( ns, type, elementId );\n// after\nif ( metaStore.getElement( ns, type, elementId ) != null ) {\n  try {\n    metaStore.deleteElement( ns, type, elementId );\n  } catch ( MetaStoreException e ) {\n    log.error( \"Delete failed: \" + e.getCause(), e );\n  }\n}","handlingStrategy":"try-catch","validationCode":"if ( metaStore.getElement( ns, elementType, elementId ) == null ) {\n  return; // nothing to delete\n}","typeGuard":null,"tryCatchPattern":"try {\n  metaStore.deleteElement( ns, type, elementId );\n} catch ( MetaStoreException e ) {\n  Throwable root = e;\n  while ( root.getCause() != null ) root = root.getCause();\n  logger.error( \"Element delete failed; root cause: {}\", root.getMessage(), e );\n}","preventionTips":["Verify element existence before deleting to avoid lookup failures","Ensure the shared objects file is writable so saveToFile() succeeds","Inspect getCause() for the actual lookup or IO error behind the generic message"],"tags":["metastore","wrapped-exception","pdi"],"backgroundTag":"internal-invariant-violation","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"}