{"record":{"id":"b6becef2e3a1200c","repo":"flowable/flowable-engine","slug":"script-content-is-null-or-evaluated-to-null-for-ta","errorCode":null,"errorMessage":"Script content is null or evaluated to null for taskListener of type 'script'","messagePattern":"Script content is null or evaluated to null for taskListener of type 'script'","errorType":"exception","errorClass":"FlowableIllegalStateException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/ScriptTypeTaskListener.java","lineNumber":61,"sourceCode":"    }\n\n    public ScriptTypeTaskListener(Expression language, Expression script) {\n        this.script = script;\n        this.language = language;\n    }\n\n    @Override\n    public void notify(DelegateTask delegateTask) {\n        validateParameters();\n\n        ScriptingEngines scriptingEngines = CommandContextUtil.getCmmnEngineConfiguration().getScriptingEngines();\n        String language = Objects.toString(this.language.getValue(delegateTask), null);\n        if (language == null) {\n            throw new FlowableIllegalStateException(\"'language' evaluated to null for taskListener of type 'script'\");\n        }\n        String script = Objects.toString(this.script.getValue(delegateTask), null);\n        if (script == null) {\n            throw new FlowableIllegalStateException(\"Script content is null or evaluated to null for taskListener of type 'script'\");\n        }\n\n        ScriptEngineRequest.Builder request = ScriptEngineRequest.builder()\n                .script(script)\n                .language(language)\n                .scopeContainer(delegateTask)\n                .traceEnhancer(trace -> trace.addTraceTag(\"type\", \"taskListener\"));\n        Object result = scriptingEngines.evaluate(request.build()).getResult();\n\n        if (resultVariable != null) {\n            String resultVariable = Objects.toString(this.resultVariable.getValue(delegateTask), null);\n            if (resultVariable != null) {\n                delegateTask.setVariable(resultVariable, result);\n            }\n        }\n    }\n\n    protected void validateParameters() {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/ScriptTypeTaskListener.java#L43-L79","documentation":"ScriptTypeTaskListener evaluates the configured 'script' expression at execution time; if it evaluates to null there is no script content to run, so it throws FlowableIllegalStateException. This is the sibling check of the null-language error and indicates the script content expression resolved to nothing.","triggerScenarios":"notify(delegateTask) evaluates this.script.getValue(delegateTask); after Objects.toString(..., null) the result is null — the script attribute was an expression resolving to null, or the script content is missing from the listener definition.","commonSituations":"script configured as ${scriptVar} where scriptVar is absent; template-generated CMMN XML with empty script body; variable holding the script text removed or renamed; script content supplied as empty string (may pass earlier checks but be rejected here depending on evaluation).","solutions":["Provide literal script content in the listener definition, or guarantee the referenced variable holding the script is set before the listener runs.","Validate the case definition at deploy time to reject script listeners with empty/missing content.","If the script must be dynamic, set the variable in a preceding plan item/listener and add a fallback expression (e.g. ${scriptVar ?: '/*noop*/'}).","Log the resolved script expression scope during development to catch nulls early."],"exampleFix":"// before\n<flowable:taskListener event=\"create\" language=\"javascript\" script=\"${dynamicScriptVar}\" /> <!-- var often null -->\n// after\n<flowable:taskListener event=\"create\" language=\"javascript\" script=\"execution.setVariable('processed', true)\" />","handlingStrategy":"validation","validationCode":"String script = scriptExpression != null ? String.valueOf(scriptExpression) : null;\nif (script == null || script.isBlank()) throw new IllegalArgumentException(\"Script task listener content must be non-empty\");","typeGuard":"boolean hasScript(FlowableListener l) {\n    return l.getScriptInfo() != null && l.getScriptInfo().getScript() != null && !l.getScriptInfo().getScript().isBlank();\n}","tryCatchPattern":"try {\n    // task create triggers script listener\n} catch (FlowableIllegalStateException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Script content is null\")) {\n        log.error(\"Script listener body unresolved; check script expression \" + scriptExpr);\n        throw new ConfigurationException(\"Provide literal or guaranteed script content\", e);\n    }\n    throw e;\n}","preventionTips":["Prefer inline literal scripts over variable-backed script bodies","If scripts must be dynamic, guarantee the variable is set before the listener fires","Add deploy-time validation rejecting empty script content"],"tags":["flowable","cmmn","script-task-listener","null-value","scripting"],"backgroundTag":"null-argument","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"}