{"record":{"id":"0451b1146d0855b6","repo":"flowable/flowable-engine","slug":"no-case-instance-found-for-id-caseinstanceid-0451b1","errorCode":null,"errorMessage":"No case instance found for id = '${caseInstanceId}'.","messagePattern":"No case instance found for id = '(.+?)'\\.","errorType":"validation","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetCaseInstanceBusinessStatusCmd.java","lineNumber":47,"sourceCode":"\n    private final String caseInstanceId;\n    private final String businessStatus;\n\n    public SetCaseInstanceBusinessStatusCmd(String caseInstanceId, String businessStatus) {\n        if (caseInstanceId == null || caseInstanceId.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"The case instance id is mandatory, but '\" + caseInstanceId + \"' has not been provided.\");\n        }\n\n        this.caseInstanceId = caseInstanceId;\n        this.businessStatus = businessStatus;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CaseInstanceEntityManager caseInstanceEntityManager = CommandContextUtil.getCaseInstanceEntityManager(commandContext);\n        CaseInstanceEntity caseInstanceEntity = caseInstanceEntityManager.findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No case instance found for id = '\" + caseInstanceId + \"'.\", CaseInstance.class);\n        }\n\n        caseInstanceEntityManager.updateCaseInstanceBusinessStatus(caseInstanceEntity, businessStatus);\n\n        return null;\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetCaseInstanceBusinessStatusCmd.java#L29-L55","documentation":"Thrown by SetCaseInstanceBusinessStatusCmd.execute when no CMMN case instance exists for the given id. Flowable looks up the CaseInstanceEntity via the entity manager before updating its business status; if findById returns null it raises FlowableObjectNotFoundException with CaseInstance.class as the referenced type. It signals that the target case instance does not exist (or was already deleted).","triggerScenarios":"Calling CmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, businessStatus) with an id that does not match any running or completed case instance.","commonSituations":"Passing a processInstanceId (BPMN) instead of a caseInstanceId; using a stale id after the case instance ended and was removed; typos or truncated ids from external storage; querying a different database/schema than the one the case was created in.","solutions":["Verify the caseInstanceId with cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).singleResult() before setting the status","Confirm you are not confusing a BPMN process instance id with a CMMN case instance id","Check you are connected to the same database/schema where the case instance was created","If the case may no longer exist, catch FlowableObjectNotFoundException and treat it as an idempotent no-op or propagate a 404"],"exampleFix":"// before\ncmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, \"ACTIVE\");\n// after\nif (cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0) {\n    cmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, \"ACTIVE\");\n} else {\n    logger.warn(\"Case instance {} not found, skipping business status update\", caseInstanceId);\n}","handlingStrategy":"validation","validationCode":"boolean exists = cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(caseInstanceId).count() > 0;\nif (!exists) { throw new IllegalArgumentException(\"Unknown caseInstanceId: \" + caseInstanceId); }","typeGuard":"boolean isValidCaseInstance(String id) { return id != null && !id.isEmpty() && cmmnRuntimeService.createCaseInstanceQuery().caseInstanceId(id).count() > 0; }","tryCatchPattern":"try {\n    cmmnRuntimeService.setCaseInstanceBusinessStatus(caseInstanceId, status);\n} catch (FlowableObjectNotFoundException e) {\n    throw new NotFoundException(\"Case instance not found: \" + caseInstanceId, e);\n}","preventionTips":["Always derive caseInstanceId from a persisted entity, never from user input unvalidated","Existence-check with a case instance query before mutation APIs","Distinguish CMMN case ids from BPMN process ids in your domain model","Map FlowableObjectNotFoundException to 404 at the REST layer"],"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"}