{"record":{"id":"e60d77614b542b8c","repo":"flowable/flowable-engine","slug":"error-coerce-value","errorCode":"error.coerce.value","errorMessage":"error.coerce.value","messagePattern":"error\\.coerce\\.value","errorType":"exception","errorClass":"ELException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/misc/TypeConverterImpl.java","lineNumber":88,"sourceCode":"\n\tprotected BigDecimal coerceToBigDecimal(Object value) {\n\t\tif (value == null || \"\".equals(value)) {\n\t\t\treturn BigDecimal.valueOf(0L);\n\t\t}\n\t\tif (value instanceof BigDecimal) {\n\t\t\treturn (BigDecimal)value;\n\t\t}\n\t\tif (value instanceof BigInteger) {\n\t\t\treturn new BigDecimal((BigInteger)value);\n\t\t}\n\t\tif (value instanceof Number) {\n\t\t\treturn new BigDecimal(((Number)value).doubleValue());\n\t\t}\n\t\tif (value instanceof String) {\n\t\t\ttry {\n\t\t\t\treturn new BigDecimal((String)value);\n\t\t\t} catch (NumberFormatException e) {\n\t\t\t\tthrow new ELException(LocalMessages.get(\"error.coerce.value\", value, value.getClass(), BigDecimal.class), e);\n\t\t\t}\n\t\t}\n\t\tif (value instanceof Character) {\n\t\t\treturn new BigDecimal((short)((Character)value).charValue());\n\t\t}\n        if (value instanceof LambdaExpression lambdaExpression) {\n            return coerceToBigDecimal(resolveLambdaExpression(lambdaExpression));\n        }\n\t\tthrow new ELException(LocalMessages.get(\"error.coerce.type\", value, value.getClass(), BigDecimal.class));\n\t}\n\n\tprotected BigInteger coerceToBigInteger(Object value) {\n\t\tif (value == null || \"\".equals(value)) {\n\t\t\treturn BigInteger.valueOf(0L);\n\t\t}\n\t\tif (value instanceof BigInteger) {\n\t\t\treturn (BigInteger)value;\n\t\t}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/de/odysseus/el/misc/TypeConverterImpl.java#L70-L106","documentation":"Thrown when a String value cannot be parsed as a BigDecimal during EL coercion in TypeConverterImpl.coerceToBigDecimal. The code catches NumberFormatException from new BigDecimal(String) and rethrows it as ELException with code error.coerce.value. Unlike error.coerce.type, the type was correct but the value's content was invalid.","triggerScenarios":"An EL expression produces a String like \"12.3abc\", \"\", locale-formatted numbers (\"1,234.56\" with grouped separators or comma decimals), currency symbols, or trailing whitespace where a BigDecimal operand is required (arithmetic, comparisons, numeric assignment).","commonSituations":"User-supplied input bound into EL variables; locale differences (German \"1.234,56\" parsed as \"1.234\"); currency/percentage strings from forms; whitespace or non-breaking spaces from spreadsheets.","solutions":["Sanitize the string before it reaches EL: strip currency symbols, grouping separators, and whitespace.","Normalize to the expected decimal format: replace ',' with '.' for decimal separators and remove thousands separators.","Parse/validate with new BigDecimal(str) in a try-catch in your own code before evaluating the expression.","Fix the source data so numeric fields contain only valid numeric text."],"exampleFix":"// before\nString amount = \"€1,234.56\"; // used in ${amount * 2}\n// after\nString amount = new BigDecimal(\"1,234.56\".replace(\"€\",\"\").replace(\",\",\"\")).toString(); // \"1234.56\"","handlingStrategy":"validation","validationCode":"try { new java.math.BigDecimal(str.trim().replace(\",\", \"\")); return true; } catch (NumberFormatException e) { return false; }","typeGuard":"static boolean isBigDecimalParsable(String s) { try { new java.math.BigDecimal(s.trim()); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try { Object r = expression.getValue(context); } catch (jakarta.el.ELException e) { if (e.getCause() instanceof NumberFormatException nfe) { log.error(\"Invalid numeric string: {}\", nfe.getMessage()); } }","preventionTips":["Normalize locale-formatted numbers before EL evaluation.","Strip currency symbols, spaces, and grouping separators from input.","Validate numeric strings with BigDecimal parse before binding.","Store numeric values as numbers, not formatted strings."],"tags":["el","number-format","bigdecimal","type-coercion"],"backgroundTag":"invalid-argument-format","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"}