{"record":{"id":"23f4626d05c427df","repo":"flowable/flowable-engine","slug":"cannot-convert-value-of-type","errorCode":null,"errorMessage":"Cannot convert value of type ","messagePattern":"Cannot convert value of type ","errorType":"validation","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/DefaultVariableValueConversionHandler.java","lineNumber":77,"sourceCode":"            if (jsonNode.isString()) {\n                return jsonNode.asString();\n            }\n            return jsonNode.toString();\n        }\n        return value.toString();\n    }\n\n    protected Integer convertToInteger(Object value) {\n        if (value instanceof Integer intValue) {\n            return intValue;\n        }\n        if (value instanceof Number number) {\n            return number.intValue();\n        }\n        if (value instanceof String stringValue) {\n            return Integer.valueOf(stringValue.trim());\n        }\n        throw new FlowableException(\"Cannot convert value of type \" + value.getClass().getName() + \" to Integer\");\n    }\n\n    protected Long convertToLong(Object value) {\n        if (value instanceof Long longValue) {\n            return longValue;\n        }\n        if (value instanceof Number number) {\n            return number.longValue();\n        }\n        if (value instanceof String stringValue) {\n            return Long.valueOf(stringValue.trim());\n        }\n        throw new FlowableException(\"Cannot convert value of type \" + value.getClass().getName() + \" to Long\");\n    }\n\n    protected Double convertToDouble(Object value) {\n        if (value instanceof Double doubleValue) {\n            return doubleValue;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/DefaultVariableValueConversionHandler.java#L59-L95","documentation":"convertToInteger is invoked by convertValue when an IO parameter is declared as type 'integer'. It accepts Numbers (via intValue()) and Strings (via Integer.valueOf on the trimmed value). If the value is neither, Flowable throws this FlowableException naming the actual Java class of the offending value.","triggerScenarios":"Passing a Boolean, Date, ObjectNode, List, Map, or byte[] value where an 'integer' IO parameter is declared, e.g. process variables bound from a JSON payload that did not coerce to int.","commonSituations":"JSON integration returns nested objects/arrays mapped to integer parameters; form data submits booleans for numeric fields; upstream code changed a variable from Integer to String-with-suffix or Long object of wrong generic type that is fine for long but here fine too — mostly non-numeric object types.","solutions":["Ensure the value bound to the 'integer' parameter is a Number or a numeric String before calling the engine.","Pre-parse the string yourself: Integer.valueOf(value.trim()) inside try/catch to surface a clearer error.","Change the declared parameter type to one matching the actual value (e.g. 'string' or 'json').","Add a custom VariableValueConversionHandler overriding convertToInteger to widen accepted input (e.g. parse BigDecimal)."],"exampleFix":"// before\nexecution.setVariable(\"count\", java.util.List.of(1,2));\n// after\nexecution.setVariable(\"count\", 2);","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Number) && !(v instanceof String s && s.trim().matches(\"-?\\\\d+\"))) {\n    throw new IllegalArgumentException(\"value for 'integer' parameter must be Number or numeric String: \" + v.getClass());\n}","typeGuard":"static boolean isIntegerCompatible(Object v) {\n    return v instanceof Number || (v instanceof String s && !s.isBlank() && s.trim().matches(\"-?\\\\d+\"));\n}","tryCatchPattern":"try {\n    Integer i = (Integer) conversionHandler.convertValue(v, \"integer\", mapper);\n} catch (FlowableException e) {\n    if (e.getMessage().contains(\"to Integer\")) { /* coerce/fallback: log class name, use default */ }\n    else throw e;\n}","preventionTips":["Coerce JSON scalars to numbers before binding process variables","Use a typed DTO layer for form/API data feeding process variables","Unit-test IO parameter bindings with representative payloads"],"tags":["flowable","io-parameter","variable-conversion","integer"],"backgroundTag":"type-mismatch","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"}