{"record":{"id":"d1d057d8377c5ef7","repo":"flowable/flowable-engine","slug":"the-case-instance-id-is-mandatory-but","errorCode":null,"errorMessage":"The case instance id is mandatory, but '","messagePattern":"The case instance id is mandatory, but '","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CaseInstanceClaimCmd.java","lineNumber":42,"sourceCode":"import org.flowable.common.engine.api.FlowableException;\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.api.FlowableObjectNotFoundException;\nimport org.flowable.common.engine.api.scope.ScopeTypes;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.identitylink.api.IdentityLinkType;\nimport org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity;\n\npublic class CaseInstanceClaimCmd implements Command<Void>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    private final String caseInstanceId;\n    private final String userId;\n\n    public CaseInstanceClaimCmd(String caseInstanceId, String userId) {\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.userId = userId;\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        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        if (userId != null) {\n            List<IdentityLinkEntity> identityLinks = cmmnEngineConfiguration.getIdentityLinkServiceConfiguration()\n                    .getIdentityLinkService().findIdentityLinksByScopeIdAndType(caseInstanceId, ScopeTypes.CMMN);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CaseInstanceClaimCmd.java#L24-L60","documentation":"The CaseInstanceClaimCmd constructor throws FlowableIllegalArgumentException when caseInstanceId is null or an empty string (length < 1). Claiming a case instance requires a concrete instance id; the command fails at construction so an invalid command never reaches execution.","triggerScenarios":"Calling cmmnTaskService/cmmnRuntimeService claim APIs with a null or \"\" caseInstanceId — e.g. claim(caseInstanceId, userId) where the id came from an unset request parameter or an empty path variable.","commonSituations":"REST handlers forwarding empty path segments; form submissions missing the hidden case instance id field; beans where the id property was never populated before invoking the service.","solutions":["Ensure caseInstanceId is non-null and non-empty before calling the claim API","Validate request inputs (e.g. @NotBlank on the id field) at the API boundary","Trim ids from external sources and reject blank values early"],"exampleFix":"// before\nif (request.getCaseInstanceId() != null) {\n    cmmnRuntimeService.claimCaseInstance(request.getCaseInstanceId(), user); // empty string still fails\n}\n// after\nif (request.getCaseInstanceId() != null && !request.getCaseInstanceId().trim().isEmpty()) {\n    cmmnRuntimeService.claimCaseInstance(request.getCaseInstanceId().trim(), user);\n}","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.trim().isEmpty()) throw new IllegalArgumentException(\"caseInstanceId is required\");","typeGuard":"boolean isValidId(String id) { return id != null && !id.trim().isEmpty(); }","tryCatchPattern":"try {\n    cmmnRuntimeService.claimCaseInstance(caseId, userId);\n} catch (FlowableIllegalArgumentException e) {\n    throw new BadRequestException(\"A case instance id must be provided\");\n}","preventionTips":["Use @NotBlank validation on id fields in REST controllers","Trim and verify path variables before calling engine commands","Ensure forms always submit the case instance id (hidden field integrity)"],"tags":["flowable","cmmn","claim","validation"],"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-14T11:17:12.474Z"}