{"record":{"id":"55ece4d3069dd6ab","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-doubles","errorCode":null,"errorMessage":"Converter can only convert doubles","messagePattern":"Converter can only convert doubles","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/DoubleRestVariableConverter.java","lineNumber":37,"sourceCode":" * @author Frederik Heremans\n */\npublic class DoubleRestVariableConverter implements RestVariableConverter {\n\n    @Override\n    public String getRestTypeName() {\n        return \"double\";\n    }\n\n    @Override\n    public Class<?> getVariableType() {\n        return Double.class;\n    }\n\n    @Override\n    public Object getVariableValue(EngineRestVariable result) {\n        if (result.getValue() != null) {\n            if (!(result.getValue() instanceof Number)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert doubles\");\n            }\n            return ((Number) result.getValue()).doubleValue();\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof Double)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert doubles\");\n            }\n            result.setValue(variableValue);\n        } else {\n            result.setValue(null);\n        }\n    }\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/DoubleRestVariableConverter.java#L19-L55","documentation":"DoubleRestVariableConverter.getVariableValue converts an engine variable value into a Double for REST output. If the stored value is non-null but not a Number, the converter cannot produce a double and throws this FlowableIllegalArgumentException.","triggerScenarios":"Reading a REST variable with type 'double' when the underlying engine value is a non-numeric object (String, Boolean, arbitrary Serializable) instead of a numeric type.","commonSituations":"Variable declared 'double' in the REST request while the engine holds a string; manual DB edits to variable tables; a custom converter wrote a non-numeric value.","solutions":["Request the variable with the REST type matching the stored value (e.g. 'string').","Re-set the variable in the engine as a numeric type (Double, Integer, Long).","Parse the value to a number before storing it if it arrives as a string from an upstream source.","Verify no custom variable converter collides with the double converter's type."],"exampleFix":"// before\nruntimeService.setVariable(executionId, \"amount\", \"3.14\");\n// after\nruntimeService.setVariable(executionId, \"amount\", 3.14);","handlingStrategy":"type-guard","validationCode":"public static boolean isNumericValue(Object v) { return v == null || v instanceof Number; }","typeGuard":"public static boolean isNumber(Object v) { return v instanceof Number; }","tryCatchPattern":"try {\n    Object d = restClient.getVariable(id, \"amount\");\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().equals(\"Converter can only convert doubles\")) {\n        // request the variable as its actual type or fix the stored value\n    } else { throw e; }\n}","preventionTips":["Set numeric variables as Double/Integer/Long, never numeric strings.","Match the REST variable type query parameter to the stored Java type.","Avoid writing variables directly to the DB; use engine APIs."],"tags":["rest","double","type-mismatch","variable-converter"],"backgroundTag":"type-mismatch","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}