{"record":{"id":"06a0c2aad94b4fff","repo":"apache/seatunnel","slug":"invalid-bytes-field","errorCode":null,"errorMessage":"Invalid bytes field","messagePattern":"Invalid bytes 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":114,"sourceCode":"                                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();\n                if (value.canConvertToLong()) {\n                    return LocalDate.ofEpochDay(Long.parseLong(dateStr));\n                }\n                DateTimeFormatter dateFormatter = fieldFormatterMap.get(fieldName);\n                if (dateFormatter == null) {\n                    dateFormatter = DateUtils.matchDateFormatter(dateStr);\n                    fieldFormatterMap.put(fieldName, dateFormatter);\n                }\n                if (dateFormatter == null) {\n                    throw new SeaTunnelJsonFormatException(\n                            CommonErrorCodeDeprecated.UNSUPPORTED_DATA_TYPE,\n                            String.format(\n                                    \"SeaTunnel can not parse this date format [%s] of field [%s]\",\n                                    dateStr, fieldName));\n                }","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-formats/seatunnel-format-json/src/main/java/org/apache/seatunnel/format/json/debezium/DebeziumRowConverter.java#L96-L132","documentation":"For BYTES-typed fields the Debezium row converter calls Jackson's value.binaryValue() to turn (base64) textual content into raw bytes. If that conversion fails (malformed base64 or non-decodable content), the converter wraps the IOException in RuntimeException(\"Invalid bytes field\").","triggerScenarios":"getValue() on a BYTES field whose JSON node is a string that is not valid base64, or otherwise not convertible to a byte array.","commonSituations":"Debezium binary.handling.mode mismatch (base64 vs. hex vs. as-string) between producer and consumer; schema evolution turning a bytes column into a text column; replayed or hand-written test payloads with fake binary values.","solutions":["Set Debezium's binary.handling.mode=base64 (or align modes) so payloads are valid base64","Validate that the JSON string for bytes fields decodes as base64 before ingestion","Check for schema evolution where the column type changed from bytes to text and update the SeaTunnel schema accordingly","Fix corrupted/upstream-produced payloads at the source"],"exampleFix":"// before\n\"binary.handling.mode\": \"hex\"   // consumer expects base64\n// after\n\"binary.handling.mode\": \"base64\"","handlingStrategy":"validation","validationCode":"JsonNode v = payload.get(\"bytesField\");\nif (v != null && v.isTextual()) {\n    try { java.util.Base64.getDecoder().decode(v.asText()); }\n    catch (IllegalArgumentException e) { throw new IllegalArgumentException(\"bytesField is not valid base64\"); }\n}","typeGuard":null,"tryCatchPattern":"try {\n    row = converter.parse(payload);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Invalid bytes field\")) {\n        log.error(\"Binary field payload is not decodable; check binary.handling.mode\", e);\n    }\n    throw e;\n}","preventionTips":["Set binary.handling.mode=base64 on Debezium sources","Spot-check binary fields in raw topic payloads after connector changes","Update the declared schema when source column types change"],"tags":["cdc","debezium","bytes","base64"],"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-23T08:17:48.524Z"}