Skip to content

Incorrect handling of default values for union fields (Avro spec mismatch) #4112

@rudikone

Description

As far as I understand, if a record field has a union type and a default value is specified, the type of the default value must match the first element of the union.

https://avro.apache.org/docs/1.12.0/specification/#complex-types

When using io.confluent:kafka-schema-registry-client and io.confluent:kafka-schema-serializer version 8.1.0, attempting to register a schema that violates this rule resulted in the following error:

org.apache.avro.AvroTypeException: Invalid default for field ...

However, after updating to version 8.1.1, these components allow such a schema to be registered without errors.

Is this behavior expected?
Does it comply with the Apache Avro specification?

I am the main contributor to the plugin
https://github.com/rudikone/avroschema-wizard-plugin

Here is an example demonstrating the behavior I described:
rudikone/avroschema-wizard-plugin@fd1bad4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions