{"record":{"id":"f85aa5bb8e9b2ab0","repo":"flowable/flowable-engine","slug":"scripttrace","errorCode":null,"errorMessage":"scriptTrace","messagePattern":"scriptTrace","errorType":"exception","errorClass":"FlowableScriptEvaluationException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/scripting/ScriptingEngines.java","lineNumber":86,"sourceCode":"                enhanceScriptTrace(request, scriptTrace);\n                notifyScriptTraceListener(scriptSuccessListener, scriptTrace);\n            }\n            return evaluationResult;\n        } catch (FlowableScriptException e) {\n            DefaultScriptTrace scriptTrace = DefaultScriptTrace.errorTrace(Duration.ofNanos(System.nanoTime() - startNanos), request, e);\n            if (LOGGER.isDebugEnabled()) {\n                LOGGER.debug(\"Caught exception evaluating script for {}. {}{}{}\", request.getScopeContainer(), request.getLanguage(), System.lineSeparator(),\n                        request.getScript());\n            }\n            enhanceScriptTrace(request, scriptTrace);\n            if (scriptErrorListener != null) {\n                notifyScriptTraceListener(scriptErrorListener, scriptTrace);\n            }\n            Throwable rootCause = ExceptionUtils.getRootCause(e);\n            if (rootCause instanceof FlowableException) {\n                throw (FlowableException) rootCause;\n            }\n            throw new FlowableScriptEvaluationException(scriptTrace, e);\n        }\n    }\n\n    protected void notifyScriptTraceListener(ScriptTraceListener listener, ScriptTrace scriptTrace) {\n        try {\n            listener.onScriptTrace(scriptTrace);\n        } catch (Exception e) {\n            LOGGER.warn(\"Exception while executing scriptTraceListener: {} with {}\", listener, scriptTrace, e);\n        }\n    }\n\n    protected void enhanceScriptTrace(ScriptEngineRequest request, DefaultScriptTrace scriptTrace) {\n        if (defaultTraceEnhancer != null) {\n            defaultTraceEnhancer.enhanceScriptTrace(scriptTrace);\n        }\n        if (request.getTraceEnhancer() != null) {\n            request.getTraceEnhancer().enhanceScriptTrace(scriptTrace);\n        }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/scripting/ScriptingEngines.java#L68-L104","documentation":"ScriptingEngines.evaluate catches exceptions thrown during script evaluation, builds a scriptTrace, and throws FlowableScriptEvaluationException(scriptTrace, e) unless the root cause is already a FlowableException (which is rethrown as-is). The thrown message text is 'scriptTrace' because the exception message is the trace string, not a fixed literal. This is the engine-level wrapper around all script failures.","triggerScenarios":"Any failure during script evaluation (ScriptException, engine lookup failure, script syntax/runtime error) that reaches ScriptingEngines.evaluate, including via evaluateScript, renderTaskForm, renderStartForm, or executeScript entry points.","commonSituations":"Broken script in a BPMN script task; missing scripting engine; script referencing missing variables; debugging via the trace to find which script and line failed.","solutions":["Read the scriptTrace embedded in FlowableScriptEvaluationException to identify the failing script and location.","Inspect getRootCause / cause chain for the underlying ScriptException details.","Fix the script content, bindings, or register the missing scripting engine per the root cause.","Register a ScriptTraceListener/ScriptErrorListener during development to log traces on every failure."],"exampleFix":"// before (swallowing the trace)\ncatch (Exception e) { log.error(\"script failed\"); }\n\n// after\ncatch (FlowableScriptEvaluationException e) {\n    log.error(\"Script failed. Trace:\\n{}\\nRoot cause:\", e.getMessage(), ExceptionUtils.getRootCause(e));\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    scriptingEngines.evaluate(script, language, resolver, scopeContainer, inputVariableContainer, storeScriptVariables);\n} catch (FlowableScriptEvaluationException e) {\n    log.error(\"Script failed. Trace:\\n{}\\nRoot cause:\", e.getMessage(), org.apache.commons.lang3.exception.ExceptionUtils.getRootCause(e), e);\n    throw e;\n}","preventionTips":["Register a ScriptTraceListener in development environments to capture traces on every failure.","Always log ExceptionUtils.getRootCause(e) for these exceptions.","Validate scripts at process-deployment time with a dry-run evaluation.","Pin the JDK and scripting engine versions to match what the scripts were written for."],"tags":["scripting","script-exception","wrapper"],"backgroundTag":"invalid-argument-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"}