{"record":{"id":"7ae1c65a28afdcb1","repo":"flowable/flowable-engine","slug":"converter-can-only-convert-big-decimal-values","errorCode":null,"errorMessage":"Converter can only convert big decimal values","messagePattern":"Converter can only convert big decimal values","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/BigDecimalRestVariableConverter.java","lineNumber":44,"sourceCode":"\n    @Override\n    public Class<?> getVariableType() {\n        return BigDecimal.class;\n    }\n\n    @Override\n    public Object getVariableValue(EngineRestVariable result) {\n        if (result.getValue() != null) {\n            return new BigDecimal(result.getValue().toString());\n        }\n        return null;\n    }\n\n    @Override\n    public void convertVariableValue(Object variableValue, EngineRestVariable result) {\n        if (variableValue != null) {\n            if (!(variableValue instanceof BigDecimal)) {\n                throw new FlowableIllegalArgumentException(\"Converter can only convert big decimal values\");\n            }\n            result.setValue(((BigDecimal) variableValue).toPlainString());\n            \n        } else {\n            result.setValue(null);\n        }\n    }\n\n}\n","sourceCodeStart":26,"sourceCodeEnd":54,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/BigDecimalRestVariableConverter.java#L26-L54","documentation":"BigDecimalRestVariableConverter is registered exclusively for BigDecimal engine variables. convertVariableValue asserts the incoming value is a BigDecimal before writing its plain-string representation into the REST variable; any other runtime type cannot be represented by this converter, so FlowableIllegalArgumentException is thrown.","triggerScenarios":"A variable value reaching this converter during REST serialization that is not a BigDecimal and not null — typically caused by a converter mis-lookup or a variable whose Java type changed between engine write and REST read.","commonSituations":"Custom REST code calling the converter directly with a Double/Integer; variables stored by an older engine version with a different numeric type; REST variable type-name mismatches causing the wrong converter to be selected for the payload.","solutions":["Ensure the value passed to convertVariableValue is a java.math.BigDecimal (wrap non-BigDecimal numerics with BigDecimal.valueOf(...)).","Verify the REST variable's type field maps to the BigDecimal converter (only send type 'bigDecimal' for BigDecimal values).","If the engine variable is actually a Double/Integer, use the appropriate converter (DoubleRestVariableConverter, IntegerRestVariableConverter) instead.","When calling the converter yourself, convert first: new BigDecimal(value.toString()) before invoking it."],"exampleFix":"// before\nconverter.convertVariableValue(3.14, restVariable); // Double -> throws\n// after\nconverter.convertVariableValue(BigDecimal.valueOf(3.14), restVariable);","handlingStrategy":"type-guard","validationCode":"if (value != null && !(value instanceof BigDecimal)) {\n    value = new BigDecimal(value.toString());\n}","typeGuard":"BigDecimal asBigDecimal(Object v) {\n    if (v instanceof BigDecimal) return (BigDecimal) v;\n    if (v instanceof Number) return new BigDecimal(v.toString());\n    return null;\n}","tryCatchPattern":"try {\n    converter.convertVariableValue(value, restVariable);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"big decimal\")) {\n        converter.convertVariableValue(new BigDecimal(value.toString()), restVariable);\n    } else throw e;\n}","preventionTips":["Match the REST variable type name ('bigDecimal') to the actual value type before conversion.","Store BigDecimal variables in the engine when you intend to use this converter.","Route other numeric types to their dedicated converters.","Add instanceof checks at boundaries where variable types come from untrusted input."],"tags":["rest","variables","type-mismatch","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"}