{"record":{"id":"f21fba532bf04ce1","repo":"flowable/flowable-engine","slug":"the-case-instance-id-is-mandatory-but-caseinst-f21fba","errorCode":null,"errorMessage":"The case instance id is mandatory, but '${caseInstanceId}' has been provided.","messagePattern":"The case instance id is mandatory, but '(.+?)' has been provided\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/UpdateCaseInstanceCmd.java","lineNumber":47,"sourceCode":" * {@link Command} that updates properties of an existing case instance.\n *\n * @author Tijs Rademakers\n */\npublic class UpdateCaseInstanceCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected CaseInstanceUpdateBuilderImpl builder;\n\n    public UpdateCaseInstanceCmd(CaseInstanceUpdateBuilderImpl builder) {\n        this.builder = builder;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        String caseInstanceId = builder.getCaseInstanceId();\n        if (caseInstanceId == null || caseInstanceId.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"The case instance id is mandatory, but '\" + caseInstanceId + \"' has been provided.\");\n        }\n\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        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n\n        if (builder.isBusinessKeySet()) {\n            caseInstanceEntityManager.updateCaseInstanceBusinessKey(caseInstanceEntity, builder.getBusinessKey());\n        }\n\n        if (builder.isBusinessStatusSet()) {\n            caseInstanceEntityManager.updateCaseInstanceBusinessStatus(caseInstanceEntity, builder.getBusinessStatus());\n        }\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/UpdateCaseInstanceCmd.java#L29-L65","documentation":"UpdateCaseInstanceCmd reads the case instance id from the CaseInstanceChangeUserStateBuilder and requires a non-empty value. A null or empty string is rejected with FlowableIllegalArgumentException, since the command cannot locate the case to modify without it.","triggerScenarios":"Calling cmmnRuntimeService.createCaseInstanceChangeUserStateBuilder() and starting the update without calling caseInstanceId(...), or calling it with an empty string.","commonSituations":"Copy-pasted builder code where the id line was dropped; an id variable that is null/empty after a failed lookup; REST layer forwarding an empty path parameter.","solutions":["Always call .caseInstanceId(id) on the builder with a non-blank id before starting the update.","Validate the id in the calling layer (null/isEmpty check) and return a 400-style error early.","Ensure the id originates from a successful CaseInstance lookup."],"exampleFix":"// before\nruntimeService.createCaseInstanceChangeUserStateBuilder().start(); // no caseInstanceId set\n// after\nruntimeService.createCaseInstanceChangeUserStateBuilder()\n    .caseInstanceId(caseInstanceId)\n    .businessKey(newBusinessKey)\n    .start();","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.isEmpty()) {\n    throw new IllegalArgumentException(\"caseInstanceId is required for the update builder\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    builder.start();\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"case instance id is mandatory\")) {\n        // caller forgot .caseInstanceId(...)\n    }\n}","preventionTips":["Always chain .caseInstanceId(id) immediately after createCaseInstanceChangeUserStateBuilder()","Validate path/query parameters at the REST layer","Write a test asserting the builder is fully populated"],"tags":["cmmn","null-argument","empty-string","builder"],"backgroundTag":"missing-required-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}