{"record":{"id":"1324fe2b4226135c","repo":"flowable/flowable-engine","slug":"the-case-instance-id-is-mandatory-but-caseinst-1324fe","errorCode":null,"errorMessage":"The case instance id is mandatory, but '${caseInstanceId}' has not been provided.","messagePattern":"The case instance id is mandatory, but '(.+?)' has not been provided\\.","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetCaseInstanceDueDateCmd.java","lineNumber":36,"sourceCode":"import org.flowable.cmmn.api.runtime.CaseInstance;\nimport org.flowable.cmmn.engine.impl.persistence.entity.CaseInstanceEntity;\nimport org.flowable.cmmn.engine.impl.persistence.entity.CaseInstanceEntityManager;\nimport org.flowable.cmmn.engine.impl.util.CommandContextUtil;\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.api.FlowableObjectNotFoundException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\n\npublic class SetCaseInstanceDueDateCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    private final String caseInstanceId;\n    private final Date dueDate;\n\n    public SetCaseInstanceDueDateCmd(String caseInstanceId, Date dueDate) {\n        if (caseInstanceId == null || caseInstanceId.length() < 1) {\n            throw new FlowableIllegalArgumentException(\"The case instance id is mandatory, but '\" + caseInstanceId + \"' has not been provided.\");\n        }\n\n        this.caseInstanceId = caseInstanceId;\n        this.dueDate = dueDate;\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.updateCaseInstanceDueDate(caseInstanceEntity, dueDate);\n\n        return null;\n    }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/SetCaseInstanceDueDateCmd.java#L18-L54","documentation":"Constructor validation in SetCaseInstanceDueDateCmd: a null or empty caseInstanceId is rejected before any command executes, throwing FlowableIllegalArgumentException. Flowable commands validate their mandatory arguments eagerly so the error surfaces at call time rather than deep inside the command context.","triggerScenarios":"Calling CmmnRuntimeService.setCaseInstanceDueDate(null, dueDate) or with \"\" as the caseInstanceId.","commonSituations":"Uninitialized or empty string variables passed from request DTOs; upstream code that never set the case instance id; JSON deserialization producing empty strings instead of null.","solutions":["Ensure the caseInstanceId is a non-empty string before invoking setCaseInstanceDueDate","Fix the source of the empty id (missing DTO field, unbound request parameter)","Catch FlowableIllegalArgumentException at the API boundary and return a 400 with a clear message"],"exampleFix":"// before\ncmmnRuntimeService.setCaseInstanceDueDate(caseInstanceId, dueDate); // caseInstanceId may be \"\"\n// after\nif (caseInstanceId == null || caseInstanceId.isEmpty()) {\n    throw new IllegalArgumentException(\"caseInstanceId must be provided\");\n}\ncmmnRuntimeService.setCaseInstanceDueDate(caseInstanceId, dueDate);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.trim().isEmpty()) {\n    throw new IllegalArgumentException(\"caseInstanceId must be a non-empty string\");\n}","typeGuard":"boolean hasCaseInstanceId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try {\n    cmmnRuntimeService.setCaseInstanceDueDate(caseInstanceId, dueDate);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"Invalid caseInstanceId: \" + e.getMessage(), e);\n}","preventionTips":["Validate request DTOs for non-blank ids before calling engine APIs","Normalize empty strings to null early so null checks catch both","Use bean validation (@NotBlank) on id fields"],"tags":["flowable","cmmn","validation","missing-argument"],"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-14T05:17:10.506Z"}