{"record":{"id":"cbb2947e339cbc4a","repo":"flowable/flowable-engine","slug":"cannot-find-case-instance-with-id-cbb294","errorCode":null,"errorMessage":"Cannot find case instance with id ","messagePattern":"Cannot find case instance with id ","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteIdentityLinkForCaseInstanceCmd.java","lineNumber":70,"sourceCode":"            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n\n        if (type == null) {\n            throw new FlowableIllegalArgumentException(\"type is required when deleting a process identity link\");\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        CaseInstance caseInstance = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);\n\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find case instance with id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n\n        IdentityLinkUtil.deleteCaseInstanceIdentityLinks(caseInstance, userId, groupId, type, cmmnEngineConfiguration);\n        \n        return null;\n    }\n\n}\n","sourceCodeStart":52,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DeleteIdentityLinkForCaseInstanceCmd.java#L52-L79","documentation":"FlowableObjectNotFoundException thrown by DeleteIdentityLinkForCaseInstanceCmd.execute when no case instance exists with the supplied caseInstanceId. The engine looked up the case instance entity before deleting identity links and found nothing.","triggerScenarios":"Calling deleteCaseInstanceIdentityLink with a caseInstanceId that was never created, was already deleted, or is a task/process id mistakenly passed in.","commonSituations":"Stale ids cached in an external app after case instance deletion; copying the wrong id column (task id vs case instance id) in admin tooling; test data cleaned up between runs; id with wrong case vs casing.","solutions":["Fetch/validate the case instance (caseService.createCaseInstanceQuery().caseInstanceId(id).singleResult()) before deleting the link","Confirm the id is a CMMN case instance id, not a task or process instance id","Handle already-deleted case instances gracefully in the caller (idempotent delete)"],"exampleFix":"// before\ncaseService.deleteCaseInstanceIdentityLink(caseInstanceId, userId, groupId, type);\n// after\nCaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).singleResult();\nif (ci != null) {\n    caseService.deleteCaseInstanceIdentityLink(caseInstanceId, userId, groupId, type);\n}","handlingStrategy":"try-catch","validationCode":"CaseInstance ci = caseService.createCaseInstanceQuery().caseInstanceId(id).singleResult(); if (ci == null) return;","typeGuard":"boolean exists = id != null && caseService.createCaseInstanceQuery().caseInstanceId(id).count() > 0;","tryCatchPattern":"try { caseService.deleteCaseInstanceIdentityLink(id, u, g, t); } catch (FlowableObjectNotFoundException e) { log.warn(\"case instance {} already gone\", id); }","preventionTips":["Cache ids with awareness of case instance deletion","Distinguish CMMN case instance ids from task/process ids in your tooling"],"tags":["cmmn","entity-not-found","case-instance","identity-link"],"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-14T11:17:12.474Z"}