{"record":{"id":"8b201defc80f5f9f","repo":"flowable/flowable-engine","slug":"executionid-is-null-8b201d","errorCode":null,"errorMessage":"executionId is null","messagePattern":"executionId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetExecutionVariableCmd.java","lineNumber":44,"sourceCode":" * @author Joram Barrez\n */\npublic class GetExecutionVariableCmd implements Command<Object>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String executionId;\n    protected String variableName;\n    protected boolean isLocal;\n\n    public GetExecutionVariableCmd(String executionId, String variableName, boolean isLocal) {\n        this.executionId = executionId;\n        this.variableName = variableName;\n        this.isLocal = isLocal;\n    }\n\n    @Override\n    public Object execute(CommandContext commandContext) {\n        if (executionId == null) {\n            throw new ActivitiIllegalArgumentException(\"executionId is null\");\n        }\n        if (variableName == null) {\n            throw new ActivitiIllegalArgumentException(\"variableName is null\");\n        }\n\n        ExecutionEntity execution = commandContext\n                .getExecutionEntityManager()\n                .findExecutionById(executionId);\n\n        if (execution == null) {\n            throw new ActivitiObjectNotFoundException(\"execution \" + executionId + \" doesn't exist\", Execution.class);\n        }\n\n        Object value;\n\n        if (isLocal) {\n            value = execution.getVariableLocal(variableName, false);\n        } else {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetExecutionVariableCmd.java#L26-L62","documentation":"GetExecutionVariableCmd.execute validates executionId and throws ActivitiIllegalArgumentException when it is null. Variables are fetched from a specific execution, so a null execution id is invalid before any database lookup happens.","triggerScenarios":"runtimeService.getVariable(executionId, variableName) / getVariableLocal(...) with a null executionId.","commonSituations":"ExecutionEntity reference was null and its getId() propagated null; process ended before the variable read so no execution id was captured; task-to-execution resolution returned nothing.","solutions":["Obtain the execution id from runtimeService.createExecutionQuery().processInstanceId(pid).singleResult().getId() or from a Task's executionId.","Guard the executionId for null before calling getVariable.","If the process may have ended, check processInstance existence first and read historical variables via HistoryService instead."],"exampleFix":"// before\nObject value = runtimeService.getVariable(executionId, \"orderId\");\n// after\nif (executionId == null) {\n    executionId = taskService.createTaskQuery().taskId(taskId).singleResult().getExecutionId();\n}\nObject value = runtimeService.getVariable(executionId, \"orderId\");","handlingStrategy":"validation","validationCode":"if (executionId == null) {\n    throw new IllegalStateException(\"executionId is required to read variables\");\n}","typeGuard":"boolean isRunningExecution(ExecutionEntity e) { return e != null && e.getId() != null; }","tryCatchPattern":"try {\n    return runtimeService.getVariable(executionId, variableName);\n} catch (ActivitiIllegalArgumentException e) {\n    throw new IllegalStateException(\"executionId/variableName must be non-null\", e);\n}","preventionTips":["Resolve execution ids from Task.getExecutionId() rather than storing them manually.","Null-check ids right after query singleResult() calls."],"tags":["execution","variable","null-argument"],"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"}