{"record":{"id":"9c98e1b6a1d29cc6","repo":"flowable/flowable-engine","slug":"empty-object-no-variables-can-be-created","errorCode":null,"errorMessage":"Empty object, no variables can be created","messagePattern":"Empty object, no variables can be created","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service-api/src/main/java/org/flowable/variable/api/delegate/EmptyVariableScope.java","lineNumber":201,"sourceCode":"    }\n\n    @Override\n    public boolean hasVariablesLocal() {\n        return false;\n    }\n\n    @Override\n    public boolean hasVariable(String variableName) {\n        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(\"Empty object, no variables can be created\");\n    }\n\n    public void createVariablesLocal(Map<String, ? extends Object> variables) {\n        throw new UnsupportedOperationException(\"Empty object, no variables can be created\");\n    }\n\n    @Override\n    public void removeVariable(String variableName) {\n        throw new UnsupportedOperationException(\"Empty object, no variables can be removed\");\n    }\n\n    @Override\n    public void removeVariableLocal(String variableName) {\n        throw new UnsupportedOperationException(\"Empty object, no variables can be removed\");\n    }\n\n    @Override\n    public void removeVariables() {","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service-api/src/main/java/org/flowable/variable/api/delegate/EmptyVariableScope.java#L183-L219","documentation":"EmptyVariableScope.createVariableLocal(String, Object) always throws UnsupportedOperationException. Unlike the setVariable family, createVariableLocal creates the variable immediately rather than deferring, which is impossible on the immutable empty scope.","triggerScenarios":"Calling createVariableLocal(name, value) on an EmptyVariableScope instance.","commonSituations":"Delegate or listener code creating task-local variables when the received scope is the empty sentinel; init code that assumes a live TaskEntity but receives a detached/ended scope.","solutions":["Check for EmptyVariableScope before creating and fetch the live task/execution via its id.","Create local variables while the scope is active inside the delegate execution.","Route variable creation through the taskService/runtimeService with an explicit taskId/executionId.","If a placeholder scope is genuinely needed, implement a custom mutable VariableScope."],"exampleFix":"// before\nscope.createVariableLocal(\"draft\", value);\n\n// after\nif (scope instanceof EmptyVariableScope) {\n    throw new IllegalStateException(\"Cannot create variables on an empty scope\");\n}\nscope.createVariableLocal(\"draft\", value);","handlingStrategy":"type-guard","validationCode":"if (scope instanceof EmptyVariableScope) {\n    throw new IllegalStateException(\"Cannot create local variables on empty scope\");\n}","typeGuard":"boolean isWritableScope(VariableScope scope) {\n    return scope != null && !(scope instanceof EmptyVariableScope);\n}","tryCatchPattern":"try {\n    scope.createVariableLocal(name, value);\n} catch (UnsupportedOperationException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Empty object\")) {\n        logger.warn(\"Create skipped: empty scope\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Create variables via the live delegate scope during execution.","For detached contexts use taskService/runtimeService create-variable operations with ids.","Check instanceof EmptyVariableScope in any generic variable helper.","Do not assume every VariableScope handed to your code is mutable."],"tags":["flowable","unsupported-operation","variable-scope","immutable"],"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"}