leo-vital opened a new issue, #252:
URL: https://github.com/apache/avro-rs/issues/252

   I have a struct like this:
   
   ```rust
   #[derive(AvroSchema)]
   struct Something {
      f: String
   }
   ```
   
   Recently I have had a problem with the schema evolution using the `BACKWARD` 
compatibility configuration in the Schema Registry. I first create an initial 
schema version just fine, but then when I add a field whose type is 
`Option<String>` to the struct above and try to encode it using 
schema-registry-converter's `encode_struct` function, I see this error in the 
Schema Registry:
   
   ```
   io.confluent.kafka.schemaregistry.exceptions.IncompatibleSchemaException: 
[{errorType:'READER_FIELD_MISSING_DEFAULT_VALUE', description:'The field 
'field_name' at path '/fields/6' in the new schema has no default value and is 
missing in the old schema', additionalInfo:'field_name'},...
   ```
   
   Looking at it deeper, I noticed that the main problem seems to be the fact 
that the canonical form does not include a default value. Even when I mark the 
field with `#[avro(default="null")]` the same behavior can be observed. Even 
though I can see that `T::get_schema()` returns a schema in which the field 
contains a default value, when I get the schema's canonical form there is no 
default value.
   
   My understanding is that this is by design due to the STRIP rule 
[here](https://github.com/apache/avro-rs/blob/d33d60014563cbe8d7b9050b9362e8fe89e1259a/avro/src/schema.rs#L2353).
 But if that is the case, then how exactly can I get a retro-compatible schema 
when adding an optional field? Is that simply not supported and I need to 
manually create a schema version in the Schema Registry?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to