Avro 1.11.0 migration from 1.8.2 causing Invalid default issue for enum union

Viewed 141

For a record, we are having a field like below

    {
      "name": "errorType",
      "type": [
        "null",
        "com.abc.xyz.ErrorEnum"
      ],
      "default": null
    }

But we are getting exception for default value

Caused by: org.apache.avro.AvroTypeException: Invalid default for field errorType: "null" not a ["null",{"type":"enum","name":"ErrorEnum","namespace":"com.abc.xyz","symbols":["INFO","ERROR","UNKNOWN"]}]

This was working well with Avro 1.8.2 but causing issue with Avro 11

1 Answers

Issue was due to an old schema with which old data was serialized. Early version of avro had a bug where it allowed "default": "null" where as "default": null was correct schema. Newer versions stopped identifying bug as right behaviour but when we upgraded and fixed schema, we went into mentioned issue.

We had to delete old schema and rewrote in this case.

Related