{"record":{"id":"a18370f1733f4461","repo":"flowable/flowable-engine","slug":"caseinstanceid-is-null-a18370","errorCode":null,"errorMessage":"caseInstanceId is null","messagePattern":"caseInstanceId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RemoveVariablesCmd.java","lineNumber":40,"sourceCode":"import org.flowable.common.engine.impl.interceptor.CommandContext;\n\n/**\n * @author Tijs Rademakers\n */\npublic class RemoveVariablesCmd implements Command<Void> {\n    \n    protected String caseInstanceId;\n    protected Collection<String> variableNames;\n    \n    public RemoveVariablesCmd(String caseInstanceId, Collection<String> variableNames) {\n        this.caseInstanceId = caseInstanceId;\n        this.variableNames = variableNames;\n    }\n    \n    @Override\n    public Void execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n        if (variableNames == null) {\n            throw new FlowableIllegalArgumentException(\"variableNames is null\");\n        }\n     \n        CaseInstanceEntity caseInstanceEntity = CommandContextUtil.getCaseInstanceEntityManager(commandContext).findById(caseInstanceId);\n        if (caseInstanceEntity == null) {\n            throw new FlowableObjectNotFoundException(\"No case instance found for id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n        caseInstanceEntity.removeVariables(variableNames);\n        \n        return null;\n    }\n\n}\n","sourceCodeStart":22,"sourceCodeEnd":56,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/RemoveVariablesCmd.java#L22-L56","documentation":"RemoveVariablesCmd removes multiple variables from a CMMN case instance and first validates its inputs. A null caseInstanceId cannot identify a target case, so it throws FlowableIllegalArgumentException immediately.","triggerScenarios":"Invoking removeVariables(null, names) via the RuntimeService API, e.g. when an optional path/id parameter was not supplied and forwarded as null.","commonSituations":"REST endpoints with missing id path param; lookup methods returning null that is passed on; test setups forgetting to set the id field.","solutions":["Guard the id for null before calling","Obtain the id from a freshly created case instance rather than a nullable field","Fail fast in your API layer with a 400 when the id parameter is missing"],"exampleFix":"// before\ncmmnRuntimeService.removeVariables(caseInstanceId, names);\n// after\nObjects.requireNonNull(caseInstanceId, \"caseInstanceId must not be null\");\ncmmnRuntimeService.removeVariables(caseInstanceId, names);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null) throw new IllegalArgumentException(\"caseInstanceId is required\");","typeGuard":null,"tryCatchPattern":"try { cmmnRuntimeService.removeVariables(id, names); } catch (FlowableIllegalArgumentException e) { log.error(\"Invalid input: {}\", e.getMessage()); }","preventionTips":["Enforce non-null id parameters in service wrappers","Validate path/request parameters at the controller layer","Create ids only via engine start-case return values"],"tags":["cmmn","null-argument","variables"],"backgroundTag":"null-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"}