avro::decode not able to handle NULL array. Thows "Incorrect token in the stream. Expected: Array start, found Null"
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start at the Json2Avro entry point and inspect how avro::jsonDecoder and avro::decode process list2 when the JSON value is null. Determine the expected behavior for nullable arrays and records, then verify that valid null values no longer fail while existing non-null decoding still works.
Written by the indexing model from the issue text.
Description
The serdes CPP code is not able to handle NULL arrays when converting json to avro.
sample excerpt of input json that fails:
,"list1":[{"test1", "test2"}],"list2":null,"listItemCount":0,.........
It bails out at "avro::decode(*json_decoder, *datum);" while handling list2. How can we make decode accept null values which could be valid in some cases. Same question applies to a record that could be null too. Thanks.
static int
Json2Avro(Serdes::Schema *schema, const std::string &json, avro::GenericDatum **datump)
{
avro::ValidSchema *avro_schema = schema->object();
std::istringstream iss(json);
auto json_is = avro::istreamInputStream(iss);
avro::DecoderPtr json_decoder = avro::jsonDecoder(*avro_schema);
avro::GenericDatum *datum = new avro::GenericDatum(*avro_schema);
try {
json_decoder->init(*json_is);
avro::decode(*json_decoder, *datum);
}
catch (const avro::Exception &ex) {
cerr << "JSON to avro transformation failed: " << ex.what() << endl;
return -1;
}
*datump = datum;
return 0;
}
- Dominant language
- C
- Stars
- 12
- Forks
- 62
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from confluentinc/libserdes
-
Difficulty 3/5 Half a day Newbie friendliness 22/100
confluentinc/libserdes#68 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 15/100
confluentinc/libserdes#66 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
confluentinc/libserdes#64 ·
-
Difficulty 5/5 Over a week Newbie friendliness 15/100
confluentinc/libserdes#63 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
confluentinc/libserdes#59 · 2 comments ·
All issues in confluentinc/libserdes
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
arduino/ArduinoCore-mbed#1126 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
security
Difficulty 1/5 Under an hour Newbie friendliness 93/100
btclib-org/btclib-secp256k1#1427 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
esmuellert/codediff.nvim#594 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 67/100