7

While running kafka consumer, i am getting following error:

Caused by: org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id 13
Caused by: org.apache.avro.AvroTypeException: Invalid default for field key_id: "null" not a ["null",{"type":"string","avro.java.string":"String"}]
    at org.apache.avro.Schema.validateDefault(Schema.java:1512)
    at org.apache.avro.Schema.access$300(Schema.java:86)
    at org.apache.avro.Schema$Field.<init>(Schema.java:493

My avro schema is like this :

{ "name": "key_id", "type": [ "null", "string" ], "default": "null"},

I have tried multiple options to solve this problem, but it is still there.

Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156
SunilS
  • 2,030
  • 5
  • 34
  • 62

1 Answers1

11

You need to set "default": null, as opposed to "default":"null":

{ "name": "key_id", "type": [ "null", "string" ], "default": null},
Giorgos Myrianthous
  • 36,235
  • 20
  • 134
  • 156