{"record":{"id":"a23cff1e6a7b425b","repo":"flowable/flowable-engine","slug":"cannot-aggregate-variable-varinstance-a23cff","errorCode":null,"errorMessage":"Cannot aggregate variable: ${varInstance}","messagePattern":"Cannot aggregate variable: (.+?)","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/delegate/JsonVariableAggregator.java","lineNumber":163,"sourceCode":"                        case JodaDateTimeType.TYPE_NAME:\n                        case UUIDType.TYPE_NAME:\n                            // For all these types it is OK to use toString as their string representation is what we want to have\n                            objectNode.put(targetVarName, varInstance.getValue().toString());\n                            break;\n                        case ByteArrayType.TYPE_NAME:\n                            objectNode.put(targetVarName, (byte[]) varInstance.getValue());\n                            break;\n                        default:\n                            if (VariableAggregatorContext.OVERVIEW.equals(context.getState())) {\n                                // We can only use the aggregated variable if we are in an overview state\n                                Object value = varInstance.getValue();\n                                if (jsonMapper.isJsonNode(value)) {\n                                    objectNode.set(targetVarName, JsonUtil.asFlowableJsonNode(value));\n                                } else {\n                                    throw new FlowableException(\"Cannot aggregate overview variable: \" + varInstance);\n                                }\n                            } else {\n                                throw new FlowableException(\"Cannot aggregate variable: \" + varInstance);\n                            }\n                    }\n                }\n\n            }\n        }\n\n        return objectNode.getImplementationValue();\n    }\n\n    @Override\n    public Object aggregateMultiVariables(DelegateExecution execution, List<? extends VariableInstance> instances, VariableAggregatorContext context) {\n        VariableJsonMapper objectMapper = processEngineConfiguration.getVariableJsonMapper();\n        FlowableArrayNode arrayNode = objectMapper.createArrayNode();\n        for (VariableInstance instance : instances) {\n            arrayNode.add(JsonUtil.asFlowableJsonNode(instance.getValue()));\n        }\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/delegate/JsonVariableAggregator.java#L145-L181","documentation":"Same aggregation path as the overview error but thrown when aggregation is NOT in OVERVIEW state and the variable value is not a JSON node. The aggregator only supports JSON-typed values in this branch of aggregateSingleVariable.","triggerScenarios":"Non-overview aggregation state receiving a variable instance whose value fails jsonMapper.isJsonNode(value) — e.g. a String, POJO or byte[] variable supplied to the JsonVariableAggregator.","commonSituations":"Child-process variables of simple types (String, Integer) collected by the JSON aggregator during parallel process-instance migrations or aggregation delegates.","solutions":["Store the aggregated variables as JSON nodes rather than plain Java types","Verify which JsonMapper is configured and that it recognizes your variable values as JSON","Filter variables before aggregation so only JSON variables reach the aggregator","Wrap primitive values into a JSON object structure before setting them as variables"],"exampleFix":"// before\nexecution.setVariable(\"status\", \"DONE\");\n// after\nexecution.setVariable(\"status\", JsonUtil.createChildObjectNode(null, \"status\", \"DONE\").get(\"status\"));","handlingStrategy":"type-guard","validationCode":"for (VariableInstance vi : varInstances) {\n    if (!jsonMapper.isJsonNode(vi.getValue())) {\n        throw new IllegalStateException(\"Variable \" + vi.getName() + \" is not JSON\");\n    }\n}","typeGuard":"boolean isJsonVariable(VariableInstance vi, FlowableJsonMapper m) {\n    return m.isJsonNode(vi.getValue());\n}","tryCatchPattern":"try {\n    result = aggregator.aggregateSingleVariable(ctx, varInstances);\n} catch (FlowableException e) {\n    logger.warn(\"Skipping non-JSON aggregation input: \" + e.getMessage());\n}","preventionTips":["Store child-process result variables as JSON nodes only","Avoid mixing primitive and JSON variable types under aggregation target names","Test aggregation with all delegate variable types"],"tags":["variables","json","aggregation"],"backgroundTag":"incompatible-source-type","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"}