{"record":{"id":"6318d0c30159c4e5","repo":"flowable/flowable-engine","slug":"condition-script-returns-non-boolean-for","errorCode":null,"errorMessage":"condition script returns non-Boolean:  () for ","messagePattern":"condition script returns non-Boolean:  \\(\\) for ","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/ScriptCondition.java","lineNumber":48,"sourceCode":"    public ScriptCondition(String expression, String language) {\n        this.expression = expression;\n        this.language = language;\n    }\n\n    @Override\n    public boolean evaluate(String elementId, DelegateExecution execution) {\n        ScriptingEngines scriptingEngines = CommandContextUtil.getProcessEngineConfiguration().getScriptingEngines();\n\n        ScriptEngineRequest.Builder builder = ScriptEngineRequest.builder()\n                .script(expression)\n                .language(language)\n                .scopeContainer(execution);\n        Object result = scriptingEngines.evaluate(builder.build()).getResult();\n        if (result == null) {\n            throw new FlowableException(\"condition script returns null: \" + expression + \" for \" + execution);\n        }\n        if (!(result instanceof Boolean)) {\n            throw new FlowableException(\"condition script returns non-Boolean: \" + result + \" (\" + result.getClass().getName() + \") for \" + execution);\n        }\n        return (Boolean) result;\n    }\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/scripting/ScriptCondition.java#L30-L54","documentation":"FlowableException thrown by ScriptCondition.evaluate when a condition script returns a value that is not a java.lang.Boolean. Flowable gateway routing requires a strict Boolean; any other type (String 'true', Integer, etc.) is rejected, with the actual value and its class included in the message.","triggerScenarios":"A condition script (e.g. groovy returning 'true' as String, or javascript returning 1/0, or returning a java.lang.String from EL ${var} where var is a String) evaluates to a non-Boolean result for a conditional flow.","commonSituations":"Variables stored as String 'true'/'false' used directly as conditions; JS engine coercing to numbers; scripts returning status codes or objects instead of a boolean comparison; language confusion between expression vs script conditions.","solutions":["End the condition script with an explicit boolean comparison, e.g. return approved == 'true' or return count > 0.","Convert string variables before use: Boolean.parseBoolean(approved) in the script or store variables as Boolean from the start.","If using EL expressions (not scripts), wrap in a comparison: ${approved == true} instead of ${approved}."],"exampleFix":"// before (groovy)\nreturn approved\n\n// after\nreturn Boolean.TRUE.equals(approved) || 'true'.equals(approved)","handlingStrategy":"validation","validationCode":"Object flag = execution.getVariable(\"approved\");\nif (!(flag instanceof Boolean)) {\n    execution.setVariable(\"approved\", Boolean.parseBoolean(String.valueOf(flag)));\n}","typeGuard":"boolean isBooleanResult(Object o) {\n    return o instanceof Boolean;\n}","tryCatchPattern":"try {\n    return (Boolean) scriptingEngines.evaluate(request).getResult();\n} catch (FlowableException e) {\n    log.error(\"non-boolean condition result: {}\", e.getMessage());\n    throw e;\n}","preventionTips":["Store boolean process variables as java.lang.Boolean, not String 'true'","End condition scripts with an explicit comparison (x > 0, == 'true')","Prefer EL expressions with explicit comparisons over bare variables","Cover each condition with a script unit test asserting a Boolean result"],"tags":["flowable","scripting","condition","type-mismatch"],"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"}