{"record":{"id":"f8bff2ae36f36581","repo":"flowable/flowable-engine","slug":"could-not-create-result-variable","errorCode":null,"errorMessage":"could not create result variable","messagePattern":"could not create result variable","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/ExecutionVariableFactory.java","lineNumber":42,"sourceCode":"\nimport org.apache.commons.lang3.StringUtils;\nimport org.flowable.common.engine.api.FlowableException;\nimport org.flowable.common.engine.impl.util.DateUtil;\nimport org.slf4j.Logger;\nimport org.slf4j.LoggerFactory;\n\n/**\n * @author Yvo Swillens\n */\npublic class ExecutionVariableFactory {\n\n    private static final Logger LOGGER = LoggerFactory.getLogger(ExecutionVariableFactory.class);\n\n    public static Object getExecutionVariable(String type, Object expressionResult) {\n\n        if (type == null || expressionResult == null) {\n            LOGGER.error(\"could not create result variable: type {} expression result {}\", type, expressionResult);\n            throw new FlowableException(\"could not create result variable\");\n        }\n\n        Object executionVariable;\n\n        try {\n            if (StringUtils.equals(\"boolean\", type)) {\n                if (expressionResult instanceof Boolean) {\n                    executionVariable = expressionResult;\n                } else {\n                    executionVariable = Boolean.valueOf(expressionResult.toString());\n                }\n            } else if (StringUtils.equals(\"string\", type)) {\n                if (expressionResult instanceof String) {\n                    executionVariable = expressionResult;\n                } else {\n                    executionVariable = expressionResult.toString();\n                }\n            } else if (StringUtils.equals(\"number\", type)) {","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-dmn-engine/src/main/java/org/flowable/dmn/engine/impl/el/ExecutionVariableFactory.java#L24-L60","documentation":"Thrown by ExecutionVariableFactory.getExecutionVariable when the mapping type or the expression result is null — it cannot build a typed execution variable without both. The factory converts raw expression results (Boolean, String, Double, date-like values) into variables of the declared type (boolean|string|number|date) used for DMN output/execution results.","triggerScenarios":"Calling getExecutionVariable(type, expressionResult) (directly or via getExecutionVariables) with a null type or a null expressionResult — e.g. an output entry evaluated to null but the DMN rule still declares an output, or a hit-policy result list containing nulls.","commonSituations":"Output expressions that legitimately evaluate to null/empty at runtime; decision tables with output clauses whose type was never set (null type string); custom code consuming the factory with unvalidated expression results.","solutions":["Ensure the output expression yields a non-null value (use an IF-ELSE output expression or a default value in the DMN model).","Check that the output clause's type is set (boolean/string/number/date) in the DMN XML or model before evaluation.","If nulls are expected, filter or substitute them before calling getExecutionVariables, or handle null outputs as 'no output' in your integration.","When calling the factory directly, assert both arguments non-null and fail with a domain-specific message."],"exampleFix":"// before\nObject v = ExecutionVariableFactory.getExecutionVariable(outputType, expressionResult); // expressionResult may be null\n// after\nif (outputType != null && expressionResult != null) {\n    Object v = ExecutionVariableFactory.getExecutionVariable(outputType, expressionResult);\n} else {\n    // treat as missing output: skip, default, or raise a validation error\n}","handlingStrategy":"validation","validationCode":"if (type != null && expressionResult != null) {\n    Object v = ExecutionVariableFactory.getExecutionVariable(type, expressionResult);\n}","typeGuard":"boolean convertible(String type, Object result) { return type != null && result != null; }","tryCatchPattern":"try {\n    Object v = ExecutionVariableFactory.getExecutionVariable(type, result);\n} catch (FlowableException e) {\n    if (\"could not create result variable\".equals(e.getMessage())) {\n        // null type or null expression result: log and treat as missing output\n    } else { throw e; }\n}","preventionTips":["Give output expressions non-null defaults (IF-ELSE) so results are never null","Set the output clause type in the DMN model","Filter null results before calling getExecutionVariables","Treat null outputs as 'no output' explicitly in your integration"],"tags":["java","dmn","null-value","variable-conversion"],"backgroundTag":"null-argument","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"}