{"record":{"id":"f05ca8cff0a0cb8e","repo":"flowable/flowable-engine","slug":"cannot-find-case-instance-with-id-f05ca8","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/GetEntityLinkChildrenForCaseInstanceCmd.java","lineNumber":48,"sourceCode":" * @author Tijs Rademakers\n */\npublic class GetEntityLinkChildrenForCaseInstanceCmd implements Command<List<EntityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String caseInstanceId;\n\n    public GetEntityLinkChildrenForCaseInstanceCmd(String caseInstanceId) {\n        this.caseInstanceId = caseInstanceId;\n    }\n\n    @Override\n    public List<EntityLink> 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 cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getEntityLinkService()\n                .findEntityLinksByScopeIdAndType(caseInstanceId, ScopeTypes.CMMN, EntityLinkType.CHILD);\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/GetEntityLinkChildrenForCaseInstanceCmd.java#L30-L56","documentation":"GetEntityLinkChildrenForCaseInstanceCmd loads the case instance before reading its CHILD entity links. If no case instance exists for the given id it throws FlowableObjectNotFoundException with the id in the message, typed to CaseInstanceEntity.class.","triggerScenarios":"Calling cmmnRuntimeService.getEntityLinkChildrenForCaseInstance(caseInstanceId) with an id of a non-existent, deleted, or completed-and-removed case instance.","commonSituations":"Using a process instance (BPMN) id instead of a case instance id; case finished and history cleanup removed it; stale reference after rollback of the case start.","solutions":["Verify the case instance exists via cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).singleResult() first","Use the correct id type (case instance id, not BPMN process instance id)","Check history tables/service if the case has already ended"],"exampleFix":"// before\nList<EntityLink> links = cmmnRuntimeService.getEntityLinkChildrenForCaseInstance(caseInstanceId);\n// after\nif (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0) {\n    List<EntityLink> links = cmmnRuntimeService.getEntityLinkChildrenForCaseInstance(caseInstanceId);\n}","handlingStrategy":"validation","validationCode":"boolean exists = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0;","typeGuard":null,"tryCatchPattern":"try { return cmmnRuntimeService.getEntityLinkChildrenForCaseInstance(id); } catch (FlowableObjectNotFoundException e) { return Collections.emptyList(); }","preventionTips":["Verify case instance existence before entity-link queries","Do not confuse BPMN process instance ids with CMMN case instance ids","Account for history cleanup removing finished case instances"],"tags":["not-found","cmmn","case-instance","entity-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"}