{"record":{"id":"84f7bb423c7df18d","repo":"flowable/flowable-engine","slug":"no-execution-active-no-variables-can-be-removed-84f7bb","errorCode":null,"errorMessage":"No execution active, no variables can be removed","messagePattern":"No execution active, no variables can be removed","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/el/NoExecutionVariableScope.java","lineNumber":228,"sourceCode":"        return false;\n    }\n\n    @Override\n    public boolean hasVariableLocal(String variableName) {\n        return false;\n    }\n\n    public void createVariableLocal(String variableName, Object value) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be created\");\n    }\n\n    public void createVariablesLocal(Map<String, ? extends Object> variables) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be created\");\n    }\n\n    @Override\n    public void removeVariable(String variableName) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be removed\");\n    }\n\n    @Override\n    public void removeVariableLocal(String variableName) {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be removed\");\n    }\n\n    @Override\n    public void removeVariables() {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be removed\");\n    }\n\n    @Override\n    public void removeVariablesLocal() {\n        throw new UnsupportedOperationException(\"No execution active, no variables can be removed\");\n    }\n\n    @Override","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/el/NoExecutionVariableScope.java#L210-L246","documentation":"NoExecutionVariableScope is a VariableScope stub used when EL/expression evaluation happens without an active execution (e.g. outside a process instance). removeVariable is one of many mutating VariableScope methods deliberately unsupported here; calling it throws UnsupportedOperationException because there is no execution to hold variables.","triggerScenarios":"Calling removeVariable(String) on a NoExecutionVariableScope instance, i.e. evaluating/removing variables in a context with no execution, such as expression evaluation outside a process or a custom delegate receiving this scope.","commonSituations":"Custom JavaDelegate/Expression code invoking variable mutations on the wrong scope object; reusing VariableScope references after the execution has ended; unit tests instantiating NoExecutionVariableScope and calling write APIs.","solutions":["Do not mutate variables on NoExecutionVariableScope; obtain the real ExecutionEntity/DelegateExecution and call its removeVariable","Guard variable-mutation code with a check that the execution is active before calling removeVariable","In tests, replace NoExecutionVariableScope with a mock/real VariableScope implementation before exercising variable APIs","If you only need read access, use getVariable (returns null) instead of mutating APIs"],"exampleFix":"// before\nscope.removeVariable(\"orderStatus\"); // UnsupportedOperationException\n// after\nif (delegateExecution != null) {\n    delegateExecution.removeVariable(\"orderStatus\");\n}","handlingStrategy":"try-catch","validationCode":"if (scope instanceof NoExecutionVariableScope) {\n    throw new IllegalStateException(\"No execution active: cannot remove variable\");\n}","typeGuard":"function hasActiveExecution(scope) {\n    return scope != null && !(scope instanceof NoExecutionVariableScope);\n}","tryCatchPattern":"try {\n    scope.removeVariable(name);\n} catch (UnsupportedOperationException e) {\n    log.warn(\"No active execution; variable {} not removed\", name, e);\n}","preventionTips":["Only mutate variables from DelegateExecution/ExecutionEntity obtained in delegate or listener callbacks","Never pass NoExecutionVariableScope into utility code that performs writes","Check execution presence/active state before variable mutation","In tests, use a concrete VariableScope implementation rather than the stub"],"tags":["activiti","unsupported-operation","variable-scope"],"backgroundTag":"unsupported-operation","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"}