{"record":{"id":"b9100330261081d9","repo":"flowable/flowable-engine","slug":"the-given-execution-execution-getclass-getna","errorCode":null,"errorMessage":"The given execution \" + execution.getClass().getName() + \" is not of type \" + VariableScope.class.getName()","messagePattern":"The given execution \" \\+ execution\\.getClass\\(\\)\\.getName\\(\\) \\+ \" is not of type \" \\+ VariableScope\\.class\\.getName\\(\\)","errorType":"exception","errorClass":"FlowableIllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/http/handler/ScriptHttpHandler.java","lineNumber":48,"sourceCode":" */\npublic class ScriptHttpHandler extends AbstractScriptEvaluator implements HttpRequestHandler, HttpResponseHandler {\n\n    public ScriptHttpHandler(Expression language, String script) {\n        super(language, script);\n    }\n\n    @Override\n    protected ScriptingEngines getScriptingEngines() {\n        return CommandContextUtil.getProcessEngineConfiguration().getScriptingEngines();\n    }\n\n    @Override\n    public void handleHttpRequest(VariableContainer execution, HttpRequest httpRequest, FlowableHttpClient client) {\n        if (execution instanceof VariableScope) {\n            ((VariableScope) execution).setTransientVariableLocal(\"httpRequest\", httpRequest);\n            evaluateScriptRequest(createScriptRequest(execution).traceEnhancer(trace -> trace.addTraceTag(\"type\", \"httpRequestHandler\")));\n        } else {\n            throw new FlowableIllegalStateException(\n                    \"The given execution \" + execution.getClass().getName() + \" is not of type \" + VariableScope.class.getName());\n        }\n    }\n\n    @Override\n    public void handleHttpResponse(VariableContainer execution, HttpResponse httpResponse) {\n        if (execution instanceof VariableScope) {\n            ((VariableScope) execution).setTransientVariableLocal(\"httpResponse\", httpResponse);\n            evaluateScriptRequest(createScriptRequest(execution).traceEnhancer(trace -> trace.addTraceTag(\"type\", \"httpResponseHandler\")));\n        } else {\n            throw new FlowableIllegalStateException(\n                    \"The given execution \" + execution.getClass().getName() + \" is not of type \" + VariableScope.class.getName());\n        }\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":64,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/http/handler/ScriptHttpHandler.java#L30-L64","documentation":"Thrown as FlowableIllegalStateException when ScriptHttpHandler.handleHttpRequest receives a VariableContainer that is not a VariableScope. The script request handler needs to store the HttpRequest as a transient local variable on the scope so the script can access it, which is only possible on VariableScope instances. Indicates the HTTP handler was invoked with an unsupported execution type.","triggerScenarios":"A BPMN HTTP task configures a script-based request handler (flowable:script handler for http request), and the engine invokes handleHttpRequest with a VariableContainer implementation that is not a VariableScope.","commonSituations":"Custom engine extensions or integration code passing a bespoke VariableContainer into the HTTP handler pipeline; using the script handler in a context (e.g. custom job/async executor) that supplies a non-scope container; framework upgrade where handler invocation types changed.","solutions":["Ensure the execution passed to the HTTP handler is an instance of org.flowable.variable.api.delegate.VariableScope (e.g. DelegateExecution / ExecutionEntity).","If you have custom invocation code, pass the underlying DelegateExecution instead of a wrapper VariableContainer.","Switch from a script HTTP handler to a delegate-expression handler if you cannot guarantee a VariableScope execution.","Check for custom VariableContainer implementations in your integration layer and make them extend VariableScope."],"exampleFix":"// before\nVariableContainer container = new MyCustomContainer();\nhttpHandler.handleHttpRequest(container, request, client);\n\n// after\nif (container instanceof VariableScope) {\n    httpHandler.handleHttpRequest(container, request, client);\n}","handlingStrategy":"type-guard","validationCode":"if (!(container instanceof VariableScope)) {\n    throw new IllegalArgumentException(\"HTTP script request handler requires a VariableScope execution\");\n}","typeGuard":"boolean isVariableScope(VariableContainer c) {\n    return c instanceof org.flowable.variable.api.delegate.VariableScope;\n}","tryCatchPattern":"try {\n    scriptHandler.handleHttpRequest(container, request, client);\n} catch (FlowableIllegalStateException e) {\n    if (e.getMessage().contains(\"is not of type\")) {\n        logger.error(\"Non-VariableScope execution passed to script HTTP handler: \" + e.getMessage());\n    } else { throw e; }\n}","preventionTips":["Pass DelegateExecution (a VariableScope) into HTTP handlers, not custom containers.","Avoid plain VariableContainer wrappers in custom HTTP handler invocation code.","Prefer delegate-expression HTTP handlers when execution type cannot be guaranteed.","Test script HTTP handlers with mocks that implement VariableScope."],"tags":["script-handler","http-handler","type-mismatch","variable-scope"],"backgroundTag":"type-mismatch","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"}