{"record":{"id":"b5abcdffdaf690dd","repo":"flowable/flowable-engine","slug":"caseinstanceid-is-null-b5abcd","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/GetVariablesCmd.java","lineNumber":44,"sourceCode":"import org.flowable.variable.service.impl.persistence.entity.VariableInstanceEntity;\n\n/**\n * @author Joram Barrez\n */\npublic class GetVariablesCmd implements Command<Map<String, Object>> {\n    \n    protected String caseInstanceId;\n    protected Collection<String> variableNames;\n\n    public GetVariablesCmd(String caseInstanceId, Collection<String> variableNames) {\n        this.caseInstanceId = caseInstanceId;\n        this.variableNames = variableNames;\n    }\n    \n    @Override\n    public Map<String, Object> execute(CommandContext commandContext) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n        \n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        List<VariableInstanceEntity> variableInstanceEntities;\n\n        if (variableNames == null || variableNames.isEmpty()) {\n            variableInstanceEntities = cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService()\n                    .findVariableInstanceByScopeIdAndScopeType(caseInstanceId, ScopeTypes.CMMN);\n        } else {\n            variableInstanceEntities = cmmnEngineConfiguration.getVariableServiceConfiguration().getVariableService()\n                    .createInternalVariableInstanceQuery()\n                    .scopeId(caseInstanceId)\n                    .withoutSubScopeId()\n                    .scopeType(ScopeTypes.CMMN)\n                    .names(variableNames)\n                    .list();\n        }\n        Map<String, Object> variables = new HashMap<>(variableInstanceEntities.size());","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetVariablesCmd.java#L26-L62","documentation":"GetVariablesCmd.execute throws FlowableIllegalArgumentException when the caseInstanceId passed to the command is null. The CMMN engine cannot look up variables without knowing which case instance they belong to, so it fails fast before querying the variable store.","triggerScenarios":"Calling cmmnRuntimeService.getVariables(null) or getVariables(null, variableNames), or programmatically constructing GetVariablesCmd with a null caseInstanceId (e.g. a variable holding the id was never assigned or an earlier lookup returned null).","commonSituations":"Passing the result of a previous API call that returned null instead of throwing (e.g. missing case instance), copying a wrong variable from process context, or invoking the command from custom code where the id string was never populated.","solutions":["Ensure the caseInstanceId value is non-null before calling getVariables; log/inspect where the id comes from","Load the case instance first via cmmnRuntimeService.createCaseInstanceQuery().caseInstanceBusinessKey(...).singleResult() and check for null","If the id may legitimately be absent, guard the call site before invoking the command"],"exampleFix":"// before\nMap<String, Object> vars = cmmnRuntimeService.getVariables(caseInstanceId);\n// after\nif (caseInstanceId == null) {\n    throw new IllegalStateException(\"No case instance id available\");\n}\nMap<String, Object> vars = cmmnRuntimeService.getVariables(caseInstanceId);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.isEmpty()) {\n    throw new IllegalArgumentException(\"caseInstanceId must be provided before fetching variables\");\n}","typeGuard":"boolean hasCaseInstanceId(String id) {\n    return id != null && !id.trim().isEmpty();\n}","tryCatchPattern":"try {\n    Map<String, Object> vars = cmmnRuntimeService.getVariables(caseInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"caseInstanceId is null\")) {\n        // recover: skip variable fetch or re-resolve the id\n    } else {\n        throw e;\n    }\n}","preventionTips":["Always obtain ids from query results and null-check singleResult() before use","Wrap engine calls in a small facade that validates ids","Avoid passing ids through chains of nullable fields; use Optional"],"tags":["flowable","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-14T11:17:12.474Z"}