{"record":{"id":"6e7d3c0b9268ca4c","repo":"apache/iceberg","slug":"unknown-type-for-binary-field-type-name-classn","errorCode":null,"errorMessage":"Unknown type for binary field. Type name: ${className}","messagePattern":"Unknown type for binary field\\. Type name: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.java","lineNumber":237,"sourceCode":"    return isNullAt(pos) ? null : getBinaryInternal(pos);\n  }\n\n  private byte[] getBinaryInternal(int pos) {\n    Object bytes = struct.get(pos, Object.class);\n\n    // should only be either ByteBuffer or byte[]\n    if (bytes instanceof ByteBuffer) {\n      return ByteBuffers.toByteArray((ByteBuffer) bytes);\n    } else if (bytes instanceof byte[]) {\n      return (byte[]) bytes;\n    } else if (bytes instanceof UUID) {\n      UUID uuid = (UUID) bytes;\n      ByteBuffer bb = ByteBuffer.allocate(16);\n      bb.putLong(uuid.getMostSignificantBits());\n      bb.putLong(uuid.getLeastSignificantBits());\n      return bb.array();\n    } else {\n      throw new IllegalStateException(\n          \"Unknown type for binary field. Type name: \" + bytes.getClass().getName());\n    }\n  }\n\n  @Override\n  public ArrayData getArray(int pos) {\n    return isNullAt(pos)\n        ? null\n        : (ArrayData)\n            convertValue(type.fields().get(pos).type().asListType(), struct.get(pos, List.class));\n  }\n\n  @Override\n  public MapData getMap(int pos) {\n    return isNullAt(pos)\n        ? null\n        : (MapData)\n            convertValue(type.fields().get(pos).type().asMapType(), struct.get(pos, Map.class));","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/data/StructRowData.java#L219-L255","documentation":"StructRowData.getBinaryInternal expects a field value that is either byte[], ByteBuffer, or java.util.UUID (fixed-length Iceberg UUID). Any other in-memory representation of a binary/fixed field triggers this IllegalStateException, signaling an internal representation bug rather than user error.","triggerScenarios":"Calling getBinary(pos) on a StructRowData whose stored value for pos is a Java object of an unexpected class (neither byte[], ByteBuffer, nor UUID) — e.g. after a schema/representation mismatch or a custom reader that stores binary fields in a different type.","commonSituations":"Custom value readers or third-party integrations that put unexpected objects into the struct; version mismatches where the reader produced a different internal type for fixed/uuid columns.","solutions":["Inspect bytes.getClass().getName() in the message and ensure the field value stored in the struct is byte[], ByteBuffer, or UUID.","Fix or update the value reader/writer that populates the struct so binary fields are stored in one of the supported types.","Convert the offending object to byte[] before storing it in the struct (e.g. ByteBuffer.array() or UUID→16-byte encoding as done in getBinaryInternal)."],"exampleFix":"// before\nObject value = storedUnknownType; // e.g. String\nstruct.set(pos, value);\n// after\nbyte[] bytes = ((ByteBuffer) value).array(); // normalize before storing\nstruct.set(pos, bytes);","handlingStrategy":"type-guard","validationCode":"Object v = struct.get(pos, Object.class);\nif (v != null && !(v instanceof byte[]) && !(v instanceof ByteBuffer) && !(v instanceof java.util.UUID)) {\n  throw new IllegalStateException(\"Unsupported binary field type: \" + v.getClass());\n}","typeGuard":"boolean isSupportedBinary(Object v) { return v == null || v instanceof byte[] || v instanceof ByteBuffer || v instanceof java.util.UUID; }","tryCatchPattern":"try { return rowData.getBinary(pos); } catch (IllegalStateException e) { return normalizeToBytes(struct.get(pos, Object.class)); }","preventionTips":["Ensure custom value readers store binary fields as byte[] or ByteBuffer","Normalize UUID columns to the 16-byte encoding before insertion","Keep iceberg-flink and iceberg-core versions aligned"],"tags":["flink","binary","type-mismatch","internal"],"backgroundTag":"internal-invariant-violation","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"}