{"record":{"id":"e8ecfbe49a543a56","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-bigdeci-e8ecfb","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to BigDecimal","messagePattern":"Unsupported convert (.+?) to BigDecimal","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":847,"sourceCode":"    default BigDecimal convertDecimal(T typeDefine, Number value) {\n        return convertDecimal(value);\n    }\n\n    default BigDecimal convertDecimal(T typeDefine, String value) {\n        return convertDecimal(value);\n    }\n\n    default BigDecimal convertDecimal(Object value) throws UnsupportedOperationException {\n        if (value instanceof BigDecimal) {\n            return (BigDecimal) value;\n        }\n        if (value instanceof Number) {\n            return convertDecimal((Number) value);\n        }\n        if (value instanceof String) {\n            return convertDecimal((String) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to BigDecimal\");\n    }\n\n    default BigDecimal convertDecimal(Number value) {\n        return new BigDecimal(value.doubleValue());\n    }\n\n    default BigDecimal convertDecimal(String value) {\n        return new BigDecimal(value);\n    }\n\n    default double convertDouble(T typeDefine, Object value) throws UnsupportedOperationException {\n        if (value instanceof Double) {\n            return (double) value;\n        }\n        if (value instanceof Number) {\n            return convertDouble(typeDefine, (Number) value);\n        }","sourceCodeStart":829,"sourceCodeEnd":865,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L829-L865","documentation":"The typeDefine-less convertDecimal(Object) handles Number and String values only; anything else causes UnsupportedOperationException naming the value's class. It indicates the DECIMAL conversion has no rule for that runtime type.","triggerScenarios":"Calling convert()/convertDecimal(Object) with unhandled classes such as byte[], char[], or custom decimal wrappers for a DECIMAL column.","commonSituations":"Custom connectors passing raw binary decimal buffers; upstream version changes altering deserialization classes; mistakenly passing structured objects instead of scalars.","solutions":["Pre-convert to BigDecimal, another Number, or a plain numeric String before calling convert","Add a custom converter branch for the class named in the message","Correct the source mapping so the field deserializes to a numeric type"],"exampleFix":"// before\nconverter.convert(rawDecimalBuffer); // throws\n// after\nBigDecimal bd = new BigDecimal(new String(rawDecimalBuffer));\nconverter.convert(bd);","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof Number) && !(v instanceof String)) {\n    throw new IllegalStateException(\"Unsupported decimal class: \" + v.getClass());\n}","typeGuard":"boolean isConvertibleToDecimal(Object v) {\n    return v instanceof Number || v instanceof String;\n}","tryCatchPattern":"try {\n    converter.convert(value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Decimal convert failed, class={}\", value.getClass(), e);\n    value = normalizeToDecimal(value);\n}","preventionTips":["Pre-convert custom decimal wrappers to BigDecimal","Avoid forwarding raw buffers/Objects through transforms","Re-verify deserialization classes after upstream version changes"],"tags":["java","type-conversion","decimal","bigdecimal"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}