{"record":{"id":"316f09efa149e6fe","repo":"flowable/flowable-engine","slug":"cannot-find-case-definition-with-id-316f09","errorCode":null,"errorMessage":"Cannot find case definition with id ","messagePattern":"Cannot find case definition with id ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteIdentityLinkForCaseDefinitionCmd.java","lineNumber":64,"sourceCode":"    }\n\n    protected void validateParams(String userId, String groupId, String caseDefinitionId) {\n        if (caseDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"caseDefinitionId is null\");\n        }\n\n        if (userId == null && groupId == null) {\n            throw new FlowableIllegalArgumentException(\"userId and groupId cannot both be null\");\n        }\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseDefinitionEntity caseDefinition = cmmnEngineConfiguration.getCaseDefinitionEntityManager().findById(caseDefinitionId);\n\n        if (caseDefinition == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find case definition with id \" + caseDefinitionId, CaseDefinition.class);\n        }\n\n        cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getIdentityLinkService()\n            .deleteScopeDefinitionIdentityLink(caseDefinition.getId(), ScopeTypes.CMMN, userId, groupId);\n\n        return null;\n    }\n\n}\n","sourceCodeStart":46,"sourceCodeEnd":74,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteIdentityLinkForCaseDefinitionCmd.java#L46-L74","documentation":"DeleteIdentityLinkForCaseDefinitionCmd.execute throws FlowableObjectNotFoundException when the CaseDefinitionEntityManager finds no case definition for the given caseDefinitionId. The id passed validation (non-null) but no deployed case definition with that id exists in the database.","triggerScenarios":"Calling deleteUserIdentityLink/deleteGroupIdentityLinkForCaseDefinition with an id from another deployment, a deleted definition, or an id that is actually a key/deployment id rather than the definition id.","commonSituations":"After redeploying or cleaning up the repository, stale ids in scripts/config no longer resolve; mixing up case definition KEY with its generated ID; running cleanup against a different database/schema.","solutions":["Resolve the current id via repositoryService.createCaseDefinitionQuery().caseDefinitionKey(key).latestVersion().singleResult().getId() instead of hardcoding the id.","Check the definition still exists (e.g. query first) and handle FlowableObjectNotFoundException gracefully.","Confirm the call runs against the same database/datasource the definition was deployed to."],"exampleFix":"// before\nrepositoryService.deleteGroupIdentityLinkForCaseDefinition(\"myCaseDef\", \"sales\", \"candidate\");\n// after\nCaseDefinition def = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(\"myCaseDef\").latestVersion().singleResult();\nif (def != null) {\n    repositoryService.deleteGroupIdentityLinkForCaseDefinition(def.getId(), \"sales\", \"candidate\");\n}","handlingStrategy":"validation","validationCode":"CaseDefinition def = repositoryService.createCaseDefinitionQuery().caseDefinitionId(caseDefinitionId).singleResult();\nif (def != null) repositoryService.deleteGroupIdentityLinkForCaseDefinition(caseDefinitionId, groupId, type);","typeGuard":null,"tryCatchPattern":"try { repositoryService.deleteGroupIdentityLinkForCaseDefinition(defId, groupId, type); } catch (FlowableObjectNotFoundException e) { log.warn(\"Case definition {} not found\", defId); }","preventionTips":["Look up the definition id by key + latestVersion at runtime instead of hardcoding.","Re-resolve ids after redeployments or repository cleanups.","Ensure the same database is used for deploy and delete."],"tags":["cmmn","case-definition","not-found","java"],"backgroundTag":"entity-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}