{"record":{"id":"36a86ce4c7eb327b","repo":"flowable/flowable-engine","slug":"invalid-variable-scope-scope","errorCode":null,"errorMessage":"Invalid variable scope: '${scope}'","messagePattern":"Invalid variable scope: '(.+?)'","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-cmmn-rest/src/main/java/org/flowable/cmmn/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-cmmn-rest/src/main/java/org/flowable/cmmn/rest/service/api/engine/variable/RestVariable.java#L47-L71","documentation":"RestVariable.getScopeFromString converts a scope string (\"global\"/\"local\", case-insensitive) into a RestVariableScope enum. Any non-null string that matches no scope name is rejected with FlowableIllegalArgumentException; null is allowed and yields null.","triggerScenarios":"Setting a variable's \"scope\" field in REST requests (or via RestVariable.setScope) to something other than global/local, e.g. \"process\", \"case\", \"Global \".","commonSituations":"Clients confusing scope vocabularies from other Flowable/Activiti APIs; whitespace or casing assumptions (casing is fine, trailing spaces are not); templated payloads with placeholder scope values.","solutions":["Use only \"global\" or \"local\" as the scope value","Omit the scope field (or send null) when default scoping is desired","Trim user-supplied input before passing to setScope","Add client-side validation mapping domain scope concepts to the two allowed names"],"exampleFix":"// before\n{\"name\":\"x\",\"scope\":\"case\",\"value\":1}\n// after\n{\"name\":\"x\",\"scope\":\"local\",\"value\":1}","handlingStrategy":"validation","validationCode":"if (scope != null && !scope.equalsIgnoreCase(\"global\") && !scope.equalsIgnoreCase(\"local\")) {\n    throw new IllegalArgumentException(\"scope must be 'global' or 'local'\");\n}","typeGuard":"RestVariableScope safeScope(String s) {\n    return (s == null || s.equalsIgnoreCase(\"global\") || s.equalsIgnoreCase(\"local\"))\n        ? RestVariable.getScopeFromString(s) : null;\n}","tryCatchPattern":"try {\n    restVariable.setScope(scopeInput);\n} catch (FlowableIllegalArgumentException e) {\n    restVariable.setScope(null); // default scope\n}","preventionTips":["Whitelist user-facing scope options to global/local in the UI/API layer","Trim and normalize scope input before sending","Document allowed scope values in your API client SDK"],"tags":["rest","variables","scope","validation"],"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-14T05:17:10.506Z"}