{"record":{"id":"2a545f05ccbb2be3","repo":"apache/seatunnel","slug":"invalid-bytes-for-decimal-field","errorCode":null,"errorMessage":"Invalid bytes for Decimal field","messagePattern":"Invalid bytes for Decimal field","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/debezium/DebeziumRowConverter.java","lineNumber":99,"sourceCode":"            case INT:\n                return value.asInt();\n            case BIGINT:\n                return value.asLong();\n            case FLOAT:\n                return value.floatValue();\n            case DOUBLE:\n                return value.doubleValue();\n            case DECIMAL:\n                if (value.isNumber()) {\n                    return value.decimalValue();\n                }\n                if (value.isBinary() || value.isTextual()) {\n                    try {\n                        return new BigDecimal(\n                                new BigInteger(value.binaryValue()),\n                                ((DecimalType) dataType).getScale());\n                    } catch (Exception e) {\n                        throw new RuntimeException(\"Invalid bytes for Decimal field\", e);\n                    }\n                }\n                if (value.has(DECIMAL_SCALE_KEY)) {\n                    return new BigDecimal(\n                            new BigInteger(value.get(DECIMAL_VALUE_KEY).binaryValue()),\n                            value.get(DECIMAL_SCALE_KEY).intValue());\n                }\n                return new BigDecimal(value.asText());\n            case STRING:\n                return value.asText();\n            case BYTES:\n                try {\n                    return value.binaryValue();\n                } catch (IOException e) {\n                    throw new RuntimeException(\"Invalid bytes field\", e);\n                }\n            case DATE:\n                String dateStr = value.asText();","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/debezium/DebeziumRowConverter.java#L81-L117","documentation":"Debezium encodes DECIMAL fields either as plain JSON numbers or as a {scale, value} object whose 'value' is base64 binary representing the unscaled BigInteger. When converting a DecimalType field, the converter found binary/textual content that could not be interpreted as a valid unscaled integer (new BigInteger(value.binaryValue()) failed), and wraps the failure in RuntimeException(\"Invalid bytes for Decimal field\").","triggerScenarios":"getValue() hitting the DecimalType branch with a node where isBinary/isTextual is true but binaryValue() does not decode to a valid integer — corrupt or wrongly-encoded decimal payloads, or a JSON field that is textual but not the expected base64/binary representation.","commonSituations":"Decimal fields written by a different Debezium encoding mode (e.g. decimal.handling.mode=double producing plain numbers vs. base64 in the {scale,value} wrapper); schema evolution changing the field representation; hand-edited or replayed CDC payloads.","solutions":["Align Debezium's decimal.handling.mode with what the converter expects (connect mode with base64 encoded bytes) and re-capture data","Inspect the raw JSON payload of the failing field to confirm the {scale,value} encoding","Add upstream normalization so decimals always arrive as either numbers or {scale,value} objects","If the source encoding is double/string, adjust the declared SeaTunnel schema type so a different converter branch runs"],"exampleFix":"// before: decimal.handling.mode=double -> plain JSON number reaches binary branch\n\"decimal.handling.mode\": \"double\"\n// after: keep binary/precise encoding\n\"decimal.handling.mode\": \"precise\"","handlingStrategy":"validation","validationCode":"JsonNode v = payload.get(\"decimalField\");\nboolean ok = v != null && (v.isNumber() || (v.isObject() && v.has(\"scale\") && v.has(\"value\")));\nif (!ok) throw new IllegalArgumentException(\"Decimal field must be a number or {scale,value} object\");","typeGuard":null,"tryCatchPattern":"try {\n    row = converter.parse(payload);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Invalid bytes for Decimal\")) {\n        log.error(\"Check Debezium decimal.handling.mode; expected base64 {scale,value} encoding\", e);\n    }\n    throw e;\n}","preventionTips":["Keep Debezium decimal.handling.mode=precise consistently across producer and consumer","Validate decimal payload shape during format upgrades","Beware replaying payloads edited by external tools"],"tags":["cdc","debezium","decimal","type-conversion"],"backgroundTag":"invalid-argument-format","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"}