{"record":{"id":"460efde0ccbca21f","repo":"apache/iceberg","slug":"unsupported-binary-type-value-getclass","errorCode":null,"errorMessage":"Unsupported binary type: + value.getClass()","messagePattern":"Unsupported binary type: \\+ value\\.getClass\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/transforms/Transform.java","lineNumber":197,"sourceCode":"        if (((Types.TimestampType) type).shouldAdjustToUTC()) {\n          return TransformUtil.humanTimestampWithZone((Long) value);\n        } else {\n          return TransformUtil.humanTimestampWithoutZone((Long) value);\n        }\n      case TIMESTAMP_NANO:\n        if (((Types.TimestampNanoType) type).shouldAdjustToUTC()) {\n          return TransformUtil.humanTimestampNanoWithZone((Long) value);\n        } else {\n          return TransformUtil.humanTimestampNanoWithoutZone((Long) value);\n        }\n      case FIXED:\n      case BINARY:\n        if (value instanceof ByteBuffer) {\n          return TransformUtil.base64encode(((ByteBuffer) value).duplicate());\n        } else if (value instanceof byte[]) {\n          return TransformUtil.base64encode(ByteBuffer.wrap((byte[]) value));\n        } else {\n          throw new UnsupportedOperationException(\"Unsupported binary type: \" + value.getClass());\n        }\n      default:\n        return value.toString();\n    }\n  }\n\n  /**\n   * Return the unique transform name to check if similar transforms for the same source field are\n   * added multiple times in partition spec builder.\n   *\n   * @return a name used for dedup\n   */\n  default String dedupName() {\n    return toString();\n  }\n}\n","sourceCodeStart":179,"sourceCodeEnd":214,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/transforms/Transform.java#L179-L214","documentation":"Thrown by TransformUtil-backed toHumanString() when rendering a BINARY-transformed value whose runtime type is neither ByteBuffer nor byte[]. Iceberg's human-string rendering of binary values base64-encodes ByteBuffer or byte[] inputs; any other object type cannot be encoded and the method fails fast with the unexpected class name.","triggerScenarios":"Calling toHumanString(value) on a bound binary transform (e.g. Transforms.identity().bind(BinaryType.get())) with a value that is neither ByteBuffer nor byte[] — e.g. a String, an InputStream, or a custom wrapper type.","commonSituations":"Passing String-encoded binary data instead of raw bytes/ByteBuffer into partition-value rendering; custom deserializers producing non-standard types for binary columns.","solutions":["Pass the value as java.nio.ByteBuffer or byte[] when rendering binary transform values","Convert other types first: ByteBuffer.wrap(stringValue.getBytes(StandardCharsets.ISO_8859_1)) only if the string truly holds raw bytes","Catch UnsupportedOperationException and convert/handle unexpected types explicitly"],"exampleFix":"// before\nString s = transform.toHumanString(\"raw-bytes\");\n// after\nString s = transform.toHumanString(ByteBuffer.wrap(\"raw-bytes\".getBytes(StandardCharsets.UTF_8)));","handlingStrategy":"type-guard","validationCode":"if (!(value instanceof ByteBuffer) && !(value instanceof byte[])) {\n  throw new IllegalArgumentException(\"Binary transform values must be ByteBuffer or byte[]\");\n}","typeGuard":"boolean isBinaryValue(Object v) {\n  return v instanceof ByteBuffer || v instanceof byte[];\n}","tryCatchPattern":"try { return transform.toHumanString(value); } catch (UnsupportedOperationException e) { return Base64.getEncoder().encodeToString(toBytes(value)); }","preventionTips":["Always pass ByteBuffer or byte[] for binary column values","Normalize deserialized binary data to ByteBuffer before partition rendering","Add a type check before calling toHumanString on binary transforms"],"tags":["java","iceberg","transform","binary","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}