{"record":{"id":"71aaf19a78b31ce2","repo":"apache/iceberg","slug":"cannot-convert-to-uuid-value-getclass-getname","errorCode":null,"errorMessage":"Cannot convert to UUID: ${value.getClass().getName()}","messagePattern":"Cannot convert to UUID: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/RecordConverter.java","lineNumber":515,"sourceCode":"      } else if (value instanceof Struct) {\n        Struct struct = (Struct) value;\n        byte[] data = config.jsonConverter().fromConnectData(null, struct.schema(), struct);\n        return new String(data, StandardCharsets.UTF_8);\n      }\n    } catch (IOException e) {\n      throw new UncheckedIOException(e);\n    }\n    throw new IllegalArgumentException(\"Cannot convert to string: \" + value.getClass().getName());\n  }\n\n  protected Object convertUUID(Object value) {\n    UUID uuid;\n    if (value instanceof String) {\n      uuid = UUID.fromString((String) value);\n    } else if (value instanceof UUID) {\n      uuid = (UUID) value;\n    } else {\n      throw new IllegalArgumentException(\"Cannot convert to UUID: \" + value.getClass().getName());\n    }\n\n    if (FileFormat.PARQUET\n        .name()\n        .toLowerCase(Locale.ROOT)\n        .equals(config.writeProps().get(TableProperties.DEFAULT_FILE_FORMAT))) {\n      return UUIDUtil.convert(uuid);\n    } else {\n      return uuid;\n    }\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) {","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/kafka-connect/kafka-connect/src/main/java/org/apache/iceberg/connect/data/RecordConverter.java#L497-L533","documentation":"RecordConverter.convertUUID throws this IllegalArgumentException when a Kafka Connect source value cannot be converted to an Iceberg UUID column value. Only java.lang.String (parsed via UUID.fromString) and java.util.UUID are accepted; any other type fails. It signals a type mismatch between the Kafka Connect record schema and the Iceberg table schema.","triggerScenarios":"A Variant/UUID field receives a Number, byte[], Map, or Struct value instead of a String or UUID; e.g. a connector config or schema maps a UUID Iceberg column to a Kafka bytes or int field.","commonSituations":"Kafka Connect JSON converter loses native UUID types and delivers a type the sink schema doesn't declare as string; custom SMTs or schema registry schemas typed a UUID field as bytes/int8; source databases export UUIDs as binary via JDBC.","solutions":["Change the Kafka Connect schema for that field to string (SchemaBuilder.string()) so convertUUID parses it with UUID.fromString","Pre-convert the value to java.util.UUID or String in an SMT before the sink connector","If data is binary UUID bytes, decode to a UUID string (e.g. 16-byte MSB/LSB hex) in a custom converter","Check the RecordConverter subclass/field mapping so the UUID column is not bound to the wrong Connect field"],"exampleFix":"// before\nSchema uuidSchema = SchemaBuilder.bytes().build(); // yields byte[] value\n// after\nSchema uuidSchema = SchemaBuilder.string().build(); // \"123e4567-e89b-...\" parses as UUID","handlingStrategy":"type-guard","validationCode":"// before sinking\nif (value != null && !(value instanceof String || value instanceof UUID)) {\n  throw new IllegalStateException(\"Field 'id' must be String or UUID, got: \" + value.getClass());\n}","typeGuard":"static boolean isUuidCompatible(Object v) {\n  return v == null || v instanceof String || v instanceof UUID;\n}","tryCatchPattern":"try {\n  converter.convertValue(value, Types.UUID_TYPE);\n} catch (IllegalArgumentException e) {\n  log.error(\"UUID conversion failed, check Connect schema for field\", e);\n  // route to DLQ or coerce: UUID.fromString(String.valueOf(value))\n}","preventionTips":["Declare UUID fields as string schema in Kafka Connect","Never let schemaless mode feed UUID columns","Add a unit test asserting record schemas match the Iceberg table schema","Use UUID string canonical form (UUID.toString) in producers"],"tags":["kafka-connect","type-mismatch","uuid"],"backgroundTag":"type-mismatch","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"}