{"record":{"id":"031b1b37f31e59ee","repo":"spring-projects/spring-security","slug":"object-identity-not-found-objectidentity","errorCode":null,"errorMessage":"Object identity not found: <objectIdentity>","messagePattern":"Object identity not found: <objectIdentity>","errorType":"exception","errorClass":"NotFoundException","httpStatus":null,"severity":"error","filePath":"acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java","lineNumber":300,"sourceCode":"\t\t\t\t\tdeleteAcl(child, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (!this.foreignKeysInDatabase) {\n\t\t\t\t// We need to perform a manual verification for what a FK would normally\n\t\t\t\t// do. We generally don't do this, in the interests of deadlock management\n\t\t\t\tList<ObjectIdentity> children = findChildren(objectIdentity);\n\t\t\t\tif (children != null) {\n\t\t\t\t\tthrow new ChildrenExistException(\n\t\t\t\t\t\t\t\"Cannot delete '\" + objectIdentity + \"' (has \" + children.size() + \" children)\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tLong oidPrimaryKey = retrieveObjectIdentityPrimaryKey(objectIdentity);\n\t\tif (oidPrimaryKey == null) {\n\t\t\tthrow new NotFoundException(\"Object identity not found: \" + objectIdentity);\n\t\t}\n\n\t\t// Delete this ACL's ACEs in the acl_entry table\n\t\tdeleteEntries(oidPrimaryKey);\n\n\t\t// Delete this ACL's acl_object_identity row\n\t\tdeleteObjectIdentity(oidPrimaryKey);\n\n\t\t// Clear the cache\n\t\tthis.aclCache.evictFromCache(objectIdentity);\n\t}\n\n\t/**\n\t * Deletes all ACEs defined in the acl_entry table belonging to the presented\n\t * ObjectIdentity primary key.\n\t * @param oidPrimaryKey the rows in acl_entry to delete\n\t */\n\tprotected void deleteEntries(Long oidPrimaryKey) {","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/spring-projects/spring-security/blob/96852e8860138a482cb13d1479573f24ff6443c6/acl/src/main/java/org/springframework/security/acls/jdbc/JdbcMutableAclService.java#L282-L318","documentation":"deleteAcl resolves the target object identity's primary key in acl_object_identity before deleting its entries and row. If retrieveObjectIdentityPrimaryKey returns null — no ACL row exists for that ObjectIdentity — the service throws NotFoundException because there is nothing to delete.","triggerScenarios":"Calling deleteAcl(objectIdentity, ...) for an ObjectIdentity that was never persisted via createAcl, or deleting twice (double-invocation of a cleanup path), or an identity whose type/identifier spelling differs from the persisted row.","commonSituations":"Synchronization jobs deleting ACLs for entities already purged; retrying a delete after a partial failure where the ACL row was already removed; deleting ACLs for test data in a fresh database; environment mismatch (ACLs live in another schema).","solutions":["Check existence first (retrieveObjectIdentityPrimaryKey or readAclById) and skip deleteAcl when absent.","Catch org.springframework.security.acls.model.NotFoundException and treat delete as a no-op (idempotent delete).","Verify the ObjectIdentity type/identifier matches acl_class/acl_object_identity exactly.","Confirm the delete is running against the correct datasource/schema."],"exampleFix":"// before\nmutableAclService.deleteAcl(oid, true);\n// after\ntry {\n    mutableAclService.deleteAcl(oid, true);\n} catch (NotFoundException ex) {\n    // ACL already gone; idempotent delete\n}","handlingStrategy":"try-catch","validationCode":"if (((JdbcMutableAclService) aclService).retrieveObjectIdentityPrimaryKey(oid) == null) {\n    return; // nothing to delete\n}","typeGuard":"null","tryCatchPattern":"try {\n    mutableAclService.deleteAcl(oid, true);\n} catch (NotFoundException e) {\n    // idempotent: ACL already gone\n}","preventionTips":["Make delete paths idempotent by swallowing NotFoundException","Avoid double-invoking delete in retry logic","Confirm identity type/identifier spelling matches persisted rows"],"tags":["spring-security","acl","not-found","delete"],"backgroundTag":"entity-not-found","analyzedSha":"96852e8860138a482cb13d1479573f24ff6443c6","analyzedAt":"2026-09-10T23:25:23.477Z","contentChangedAt":"2026-09-10T23:25:23.477Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}