{"record":{"id":"1ef345883583791f","repo":"flowable/flowable-engine","slug":"invalid-variable-scope-scope-1ef345","errorCode":null,"errorMessage":"Invalid variable scope: '\" + scope + \"'","messagePattern":"Invalid variable scope: '\" \\+ scope \\+ \"'","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-rest/src/main/java/org/flowable/rest/service/api/engine/variable/RestVariable.java","lineNumber":65,"sourceCode":"        String scope = null;\n        if (variableScope != null) {\n            scope = variableScope.name().toLowerCase();\n        }\n        return scope;\n    }\n\n    public void setScope(String scope) {\n        setVariableScope(getScopeFromString(scope));\n    }\n\n    public static RestVariableScope getScopeFromString(String scope) {\n        if (scope != null) {\n            for (RestVariableScope s : RestVariableScope.values()) {\n                if (s.name().equalsIgnoreCase(scope)) {\n                    return s;\n                }\n            }\n            throw new FlowableIllegalArgumentException(\"Invalid variable scope: '\" + scope + \"'\");\n        } else {\n            return null;\n        }\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":71,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/engine/variable/RestVariable.java#L47-L71","documentation":"RestVariable.getScopeFromString maps a scope string (global/local, case-insensitive) to a RestVariableScope enum. A string that matches no enum constant name triggers FlowableIllegalArgumentException; this runs whenever setScope is called with a non-null value on REST variable payloads.","triggerScenarios":"Deserializing/setting the \"scope\" field of a RestVariable with a value other than GLOBAL or LOCAL (e.g. \"execution\", \"task\", \"process\"), from variable GET/PUT request payloads or query parameters.","commonSituations":"Clients using Activiti-style scope names (\"execution\"/\"task\") that Flowable's REST API does not accept, untrimmed whitespace, or custom code calling setScope with engine-level strings.","solutions":["Send only \"global\" or \"local\" for the scope field (case-insensitive).","Omit the scope field if the default is acceptable (it maps to null).","Trim/clean the scope string before calling setScope.","Replace legacy Activiti scope vocabulary (execution/task) with Flowable's global/local."],"exampleFix":"// before\nrestVariable.setScope(\"execution\");\n// after\nrestVariable.setScope(\"local\");","handlingStrategy":"type-guard","validationCode":"if (scope != null && !scope.trim().equalsIgnoreCase(\"global\") && !scope.trim().equalsIgnoreCase(\"local\")) {\n    throw new IllegalArgumentException(\"Scope must be global or local\");\n}","typeGuard":"boolean isValidScope(String s) { return s == null || \"global\".equalsIgnoreCase(s) || \"local\".equalsIgnoreCase(s); }","tryCatchPattern":"try { restVariable.setScope(scope); } catch (FlowableIllegalArgumentException e) { /* normalize to global/local */ }","preventionTips":["Send only global/local (case-insensitive)","Trim scope strings from user input","Replace legacy Activiti execution/task scope vocabulary"],"tags":["flowable","rest","variables","invalid-enum"],"backgroundTag":"invalid-enum-value","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"}