{"record":{"id":"b08df34b310bdc05","repo":"flowable/flowable-engine","slug":"case-instance-id-is-null","errorCode":null,"errorMessage":"Case instance id is null","messagePattern":"Case instance id is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AbstractNeedsCaseInstanceCmd.java","lineNumber":39,"sourceCode":"import org.flowable.common.engine.api.FlowableObjectNotFoundException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\n\n/**\n * @author Joram Barrez\n */\npublic abstract class AbstractNeedsCaseInstanceCmd implements Command<Void>, Serializable {\n    \n    protected String caseInstanceId;\n\n    public AbstractNeedsCaseInstanceCmd(String caseInstanceId) {\n        this.caseInstanceId = caseInstanceId;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"Case instance id is null\");\n        }\n        \n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstanceEntity caseInstanceEntity = cmmnEngineConfiguration.getCaseInstanceEntityManager().findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find case instance for id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n        \n        internalExecute(commandContext, caseInstanceEntity);\n        return null;\n    }\n    \n    protected abstract void internalExecute(CommandContext commandContext, CaseInstanceEntity caseInstanceEntity);\n   \n}\n","sourceCodeStart":21,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AbstractNeedsCaseInstanceCmd.java#L21-L55","documentation":"FlowableIllegalArgumentException thrown in AbstractNeedsCaseInstanceCmd.execute when the caseInstanceId field is null. The abstract command validates its required id argument before any database lookup, since a null id can never resolve. Any concrete command extending this class (e.g. changing case state, completing a form) inherits this guard.","triggerScenarios":"Calling a CMMN API such as runtimeService.trigger/case-state commands or task form commands with a null caseInstanceId argument; constructing the command object without setting the id; passing a variable that was never populated (e.g. missing request parameter mapped into the call).","commonSituations":"REST/HTTP layer where the caseInstanceId path/query parameter was absent and the null propagated into the service call; batch jobs processing lists where an entry lacks the id; misuse of a builder/constructor overload omitting the id.","solutions":["Validate the caseInstanceId at the caller level before invoking the CMMN runtime/task service API","Log and reject requests that lack the case instance id parameter in your REST/controller layer","Check the code path that produced the id (e.g. a previous query result) for null returns","Use the correct constructor/builder overload that sets caseInstanceId"],"exampleFix":"// before\ncmmnRuntimeService.caseInstanceStateChange(caseInstanceId, CaseInstanceState.TERMINATED); // caseInstanceId may be null\n// after\nif (caseInstanceId == null || caseInstanceId.isBlank()) {\n    throw new IllegalArgumentException(\"caseInstanceId must be provided\");\n}\ncmmnRuntimeService.caseInstanceStateChange(caseInstanceId, CaseInstanceState.TERMINATED);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.isBlank()) throw new IllegalArgumentException(\"caseInstanceId is required\");","typeGuard":"boolean hasCaseInstanceId(String id) { return id != null && !id.isBlank(); }","tryCatchPattern":"try { cmmnRuntimeService.caseInstanceStateChange(id, state); }\ncatch (FlowableIllegalArgumentException e) { log.error(\"Missing/invalid caseInstanceId: {}\", e.getMessage()); }","preventionTips":["Validate required ids at the API/controller boundary","Use Objects.requireNonNull on ids before engine calls","Map optional REST parameters to a required 400 response, not null into the engine","Keep id-creation and id-consumption paths in the same service layer"],"tags":["flowable","cmmn","null-argument","case-instance"],"backgroundTag":"null-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"}