{"record":{"id":"3b08e4ee6a037218","repo":"flowable/flowable-engine","slug":"cannot-find-case-instance-with-id-3b08e4","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/GetIdentityLinksForCaseInstanceCmd.java","lineNumber":48,"sourceCode":" */\npublic class GetIdentityLinksForCaseInstanceCmd implements Command<List<IdentityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String caseInstanceId;\n\n    public GetIdentityLinksForCaseInstanceCmd(String caseInstanceId) {\n        this.caseInstanceId = caseInstanceId;\n    }\n\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    @Override\n    public List<IdentityLink> 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        return (List) cmmnEngineConfiguration.getIdentityLinkServiceConfiguration().getIdentityLinkService()\n                .findIdentityLinksByScopeIdAndType(caseInstanceId, ScopeTypes.CMMN);\n    }\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetIdentityLinksForCaseInstanceCmd.java#L30-L56","documentation":"Thrown by GetIdentityLinksForCaseInstanceCmd when no CaseInstance exists with the given id. The command loads the instance through CaseInstanceEntityManager.findById and throws FlowableObjectNotFoundException when the lookup returns null. The id is a runtime (not historical/deleted) case instance id.","triggerScenarios":"Calling cmmnRuntimeService.getIdentityLinksForCaseInstance(caseInstanceId) with an id of an already-completed case, a case started in another engine/database, or a mistyped/never-created id.","commonSituations":"Querying identity links for cases that ended and were removed (or only exist in history tables); environment mismatch between where the case was started and where it is queried; id confusion between case instance id and business key.","solutions":["Confirm the case instance is still running: check cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).count() > 0.","If the case has ended, query history instead (cmmnHistoryService) for identity links if available.","Make sure both start and query use the same engine/database; add tenant checks if multi-tenant.","Log and validate the id at the call site; do not pass business keys as instance ids."],"exampleFix":"// before\nList<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForCaseInstance(caseId);\n// after\nif (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseId).count() == 0) {\n    throw new IllegalStateException(\"Case instance not found: \" + caseId);\n}\nList<IdentityLink> links = cmmnRuntimeService.getIdentityLinksForCaseInstance(caseId);","handlingStrategy":"validation","validationCode":"if (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() == 0) {\n    throw new IllegalArgumentException(\"Unknown case instance id: \" + caseInstanceId);\n}","typeGuard":"boolean caseInstanceRunning(String id) {\n    return cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).count() > 0;\n}","tryCatchPattern":"try {\n    links = cmmnRuntimeService.getIdentityLinksForCaseInstance(caseInstanceId);\n} catch (FlowableObjectNotFoundException e) {\n    log.warn(\"Case instance {} not found (completed or wrong db)\", caseInstanceId);\n    links = Collections.emptyList();\n}","preventionTips":["Check the case instance query before identity-link calls","Use history services for ended cases","Never confuse business key with instance id","Pin all services to one engine/database"],"tags":["flowable","cmmn","not-found","case-instance"],"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"}