{"record":{"id":"cfff7e65b14e9f56","repo":"apache/iceberg","slug":"parsing-binary-value-threw-exception-for-fieldna","errorCode":null,"errorMessage":"parsing binary value threw exception for ${fieldName}","messagePattern":"parsing binary value threw exception for (.+?)","errorType":"exception","errorClass":"JsonToMapException","httpStatus":null,"severity":"error","filePath":"kafka-connect/kafka-connect-transforms/src/main/java/org/apache/iceberg/connect/transforms/JsonToMapUtils.java","lineNumber":276,"sourceCode":"      default:\n        throw new JsonToMapException(\n            String.format(\"Unexpected type %s for field %s\", type, fieldName));\n    }\n    return obj;\n  }\n\n  private static Object extractBytes(JsonNode node, String fieldName) {\n    Object obj;\n    try {\n      if (node.isBigInteger()) {\n        obj = new BigDecimal(node.bigIntegerValue());\n      } else if (node.isBigDecimal()) {\n        obj = node.decimalValue();\n      } else {\n        obj = node.binaryValue();\n      }\n    } catch (Exception e) {\n      throw new JsonToMapException(\n          String.format(\"parsing binary value threw exception for %s\", fieldName), e);\n    }\n    return obj;\n  }\n\n  private static List<Object> populateArray(\n      JsonNode node, Schema schema, String fieldName, List<Object> acc) {\n    if (schema.type() == Schema.Type.ARRAY) {\n      node.elements()\n          .forEachRemaining(\n              arrayNode -> {\n                List<Object> nestedList = Lists.newArrayList();\n                acc.add(populateArray(arrayNode, schema.valueSchema(), fieldName, nestedList));\n              });\n    } else {\n      node.elements()\n          .forEachRemaining(\n              arrayEntry -> acc.add(extractValue(arrayEntry, schema.type(), fieldName)));","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/kafka-connect/kafka-connect-transforms/src/main/java/org/apache/iceberg/connect/transforms/JsonToMapUtils.java#L258-L294","documentation":"extractBytes wraps the Jackson node binary decoding (`node.binaryValue()`) in a try/catch and rethrows any exception as JsonToMapException noting the field name. It means the JSON node could not be decoded as a Base64 binary value for a BYTES-typed field.","triggerScenarios":"extractValue routes a BYTES-typed field to extractBytes and the Jackson JsonNode is not valid Base64 binary data (e.g. an arbitrary string or malformed base64), causing node.binaryValue() to throw.","commonSituations":"JSON payloads where a bytes field contains a plain string or non-Base64-encoded data; producers changed encoding; hand-crafted test payloads with invalid Base64.","solutions":["Ensure the JSON value for the field is valid Base64-encoded binary data.","Base64-encode the bytes on the producing side before sending.","Change the field's schema type to STRING if the data is actually textual."],"exampleFix":"// before\n{\"payload\": \"not-valid-base64!!\"}\n// after\n{\"payload\": \"aGVsbG8=\"}","handlingStrategy":"validation","validationCode":"// Validate Base64 before producing/sending the record\ntry { java.util.Base64.getDecoder().decode(rawValue); } catch (IllegalArgumentException e) { /* fix payload upstream */ }","typeGuard":"boolean isBase64(String s) { try { java.util.Base64.getDecoder().decode(s); return true; } catch (IllegalArgumentException e) { return false; } }","tryCatchPattern":"try { ... } catch (org.apache.iceberg.connect.transforms.JsonToMapException e) { log.error(\"Bytes field invalid at \" + e.getMessage(), e); /* route to DLQ */ }","preventionTips":["Always Base64-encode BYTES fields on the producing side","Validate payloads with a JSON schema including base64 content encoding","Watch for producers changing field encoding without versioning"],"tags":["kafka-connect","json","base64"],"backgroundTag":"json-parse-error","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}