confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
78 stars 866 forks source link

Unspecified attributes of an Avro Schema are not saved to the Schema Registry #636

Open unfw opened 6 years ago

unfw commented 6 years ago

Description

The schema saved to schema registry does not save all attributes in an Avro object. For example if we include a "doc" property, it is not saved by the schema registry package which can cause compatibility issues. According to the Avro spec, unspecified attributes are allowed as metadata but must not affect the format of the serialized data.

How to reproduce

Have a schema with property types that are not saved such as below and write a message to a topic with producer.ProduceAsync

{
  "type": "record",
  "name": "Test",
  "doc": "Test Doc",
  "fields": [
    {
      "name": "Guid",
      "type": {
        "type": "string",
        "logicalType": "guid"
      }
    }
  ]
}

Output:

You will see in the schema registry the following schema which removes the non specified attributes.

{
  "type": "record",
  "name": "Test",
  "fields": [
    {
      "name": "Guid",
       "type": "string",
    },
  ]
}

Checklist

Please provide the following information:

mhowlett commented 6 years ago

the .net avro library doesn't support logical types. As far as i know, this is only implemented in the java library.

it looks as though the avrogen program omits doc strings from the generated classes so if the serializer auto-registers them with schema the doc string will be omitted. this is unfortunate. as a work around, you could turn off auto schema registration and make sure schemas are registered using the schema registry REST api before use.