Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kafka REST proxy mandates field with null values for optional fields of AVRO schema #427

Open
keyankay opened this issue Apr 23, 2018 · 5 comments

Comments

@keyankay
Copy link

keyankay commented Apr 23, 2018

I have plenty of optional fields in my AVRO schema, and i do not want to send value as null for all the fields that are optional (there are about 20 optional fields and 5 mandatory fields) via JSON

The Kafka REST proxy is asking for the attribute to be specified even though default has been specified to null.

Ex: "schema": " { "namespace" : "sample", "type" : "record", "name" : "samp", "fields": [ {"name" : "header", "type": { "type" : "record", "name" : "sub_header", "fields" : [ {"name" : "version", "type" : "string", "default" : "NONE"}, {"name" : "id", "type" : "string", "default" : null}, {"name" : "messageID", "type" : "string", "default" : "NONE"} ] } } ] }"}

Also i tried using union {"name" : "id", "type" : ["null","string"], "default" : null} . It did not help still

Now when i want to populate the JSON data: i want to avoid sending the field "id" in the curl command, but it is failing

curl -X POST_schema_id": 93, "records": [{"value": {"sub_header" : {"version" : "images/img.png","messageID" : "123" }}}]}' "http://localhost:8082/topics/avrotest2"

{"error_code":42203,"message":"Conversion of JSON to Avro failed: Failed to convert JSON to Avro: Expected field name not found: id"}

However the below works:
curl -X POST_schema_id": 93, "records": [{"value": {"sub_header" : {"version" : "images/img.png","id":null,"messageID" : "123" }}}]}' "http://localhost:8082/topics/avrotest2"

I see that it has been fixed in AVRO for Java script : mtth/avsc#118

@keyankay keyankay changed the title Kafka REST proxy mandates null for optional fields Kafka REST proxy mandates null for optional fields for AVRO schema Apr 23, 2018
@keyankay keyankay changed the title Kafka REST proxy mandates null for optional fields for AVRO schema Kafka REST proxy mandates null for optional fields of AVRO schema Apr 23, 2018
@keyankay keyankay changed the title Kafka REST proxy mandates null for optional fields of AVRO schema Kafka REST proxy mandates field with null values for optional fields of AVRO schema Apr 23, 2018
@yatharthranjan
Copy link

Is there a particular reason this has not been attended to yet? Seeing as the major USP of avro is schema evolution, this is causing a great obstacle to that. We are facing similar problem -- RADAR-base/RADAR-Schemas#153

Would be good to know if there is a planned fix for this in the near future @ewencp @mageshn .

@ijesh
Copy link

ijesh commented Feb 27, 2020

Running into a similar issue myself. How are people getting around this issue? are there any workarounds? Doesn't seem like this issue is going to get looked at anytime soon. The issue seems to have been introduced here per this comment.
Open ticket AVRO-2447

@reneveyj
Copy link

Any workaround? This is really needed.

@RaviVaranasi
Copy link

+1 on this. Seems odd to define default values only to state to client that it is required

@Mnantier
Copy link

I'm also currently running into this issue. Has anyone figured out a solution for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants