8000 Produce to topic: avro with nullable can't be produced · Issue #407 · tchiotludo/akhq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Produce to topic: avro with nullable can't be produced #407
Closed
@zaghdous

Description

@zaghdous

Dear Ludovic, I reopen the issue that you closed because I really like your product and like to use it in my organization.
My goal is not to flood you with issues ! I think that the "produce to topic" function is cool but does not work since any given bad encoded JSON cannot be handled. Try to take the json you display and use it to produce a new message, you will get a "org.apache.avro.AvroTypeException" !

So here is the avro spec (link that I already added in the previous ticket) :

http://avro.apache.org/docs/current/spec.html#json_encoding

And an example of serde using avro-tools (we always learn even if you are a specialist):

test.asvc :
{
"type" : "record",
"name" : "recordName",
"namespace" : "name.space",
"fields" : [ {
"name" : "id",
"type" : ["null", "int"]
} ]
}

bad.json:

{
"id" : 141
}

good.json:
{
"id" : {"int" : 141}
}

$ java -jar avro-tools-1.10.0.jar fromjson --schema-file test.asvc bad.json > test.avro
Exception in thread "main" org.apache.avro.AvroTypeException: Expected start-union. Got VALUE_NUMBER_INT

$ java -jar avro-tools-1.10.0.jar fromjson --schema-file test.asvc good.json > test.avro
OK

$ java -jar avro-tools-1.10.0.jar tojson test.avro > test.json

test.json :

{
"id" : {"int" : 141}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendNeed a backend updatebugSomething isn't workingtopic dataKafka Topic data

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0