{"record":{"id":"2eb7b291c8637ef1","repo":"apache/seatunnel","slug":"cannot-convert-to-binary","errorCode":null,"errorMessage":"Cannot convert to binary: ","messagePattern":"Cannot convert to binary: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java","lineNumber":383,"sourceCode":"\n    protected UUID convertUUID(Object value) {\n        if (value instanceof String) {\n            return UUID.fromString((String) value);\n        } else if (value instanceof UUID) {\n            return (UUID) value;\n        }\n        throw new IllegalArgumentException(\"Cannot convert to UUID: \" + value.getClass().getName());\n    }\n\n    protected ByteBuffer convertBase64Binary(Object value) {\n        if (value instanceof String) {\n            return ByteBuffer.wrap(Base64.getDecoder().decode((String) value));\n        } else if (value instanceof byte[]) {\n            return ByteBuffer.wrap((byte[]) value);\n        } else if (value instanceof ByteBuffer) {\n            return (ByteBuffer) value;\n        }\n        throw new IllegalArgumentException(\n                \"Cannot convert to binary: \" + value.getClass().getName());\n    }\n\n    protected LocalDate convertDateValue(Object value) {\n        if (value instanceof Number) {\n            int days = ((Number) value).intValue();\n            return DateTimeUtil.dateFromDays(days);\n        } else if (value instanceof String) {\n            return LocalDate.parse((String) value);\n        } else if (value instanceof LocalDate) {\n            return (LocalDate) value;\n        } else if (value instanceof Date) {\n            int days = (int) (((Date) value).getTime() / 1000 / 60 / 60 / 24);\n            return DateTimeUtil.dateFromDays(days);\n        }\n        throw new RuntimeException(\"Cannot convert date: \" + value);\n    }\n","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java#L365-L401","documentation":"Iceberg RowConverter throws this when a binary column value is not String (Base64), byte[], or ByteBuffer. convertBase64Binary supports exactly those three representations; anything else is rejected with the class name in the message.","triggerScenarios":"convertBase64Binary receives e.g. an Integer, BigDecimal, or arbitrary object while converting a field to an Iceberg BINARY column.","commonSituations":"Binary data serialized as JSON arrays/ints by a non-conforming source; nested structures mistakenly mapped to BINARY; file sources emitting image bytes wrapped in custom types.","solutions":["Ensure the source emits byte[] or Base64-encoded String for binary fields.","Add a transform to encode the value as Base64 string before the sink.","Verify SeaTunnel schema maps the column to BytesType, not another type."],"exampleFix":"// before\nwriter.write(idx, someCustomBlobObject);\n// after\nwriter.write(idx, Base64.getEncoder().encodeToString(blobBytes)); // String accepted","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof String) && !(v instanceof byte[]) && !(v instanceof ByteBuffer)) throw new IllegalArgumentException(\"binary column must be String/byte[]/ByteBuffer, got \" + (v == null ? \"null\" : v.getClass().getName()));","typeGuard":"boolean isBinaryConvertible(Object v) { return v instanceof String || v instanceof byte[] || v instanceof ByteBuffer; }","tryCatchPattern":"try { sink.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Cannot convert to binary\")) { /* encode to Base64 or DLQ */ } else throw e; }","preventionTips":["Map source binary columns to SeaTunnel BytesType","Base64-encode binary values when passing through JSON/text pipelines","Avoid wrapping bytes in custom types before the sink"],"tags":["iceberg","type-conversion","binary","sink"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}