[
https://issues.apache.org/jira/browse/AVRO-4117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17929247#comment-17929247
]
Joshua Humphries commented on AVRO-4117:
----------------------------------------
I think this was actually a duplicate of AVRO-4026.
The merged fix makes it possible to load most Avro files that have such custom
attributes, but it still isn't robust. For example, string values provided to
`CustomAttributes` still need internal escaping if they contain characters like
quotes or newlines. Also, it still isn't possible to generate Avro files with
non-string attributes.
In case anyone is interested in helping me get this fixed: I've got a more
complete solution that I've proposed as a fix to AVRO-4026, but I'm having some
trouble getting it reviewed and merged. It's here:
[https://github.com/apache/avro/pull/3266.]
> avrocpp throws an exception if unreserved key in schema has a non string value
> ------------------------------------------------------------------------------
>
> Key: AVRO-4117
> URL: https://issues.apache.org/jira/browse/AVRO-4117
> Project: Apache Avro
> Issue Type: Bug
> Components: c++
> Affects Versions: 1.11.4
> Environment: Linux
> c++17
> Reporter: Manik Malhotra
> Assignee: Manik Malhotra
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.13.0
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> Steps to reproduce:
> 1. Create cpx.json schema file:
> {code:java}
> {
> "fields": [
> {
> "type": [
> {
> "minItems": 1,
> "type": "array",
> "items": "string"
> }
> ],
> "name": "bug"
> }
> ],
> "type": "record",
> "name": "cpx"
> } {code}
> 2. Create bug.cpp file
> {code:java}
> #include <fstream>
> #include <avro/ValidSchema.hh>
> #include <avro/Schema.hh>
> #include <avro/Compiler.hh>int main(int argc, char* argv[])
> {
> if (argc < 2) {
> std::cerr << "Usage: " << argv[0] << " <schema json>" << std::endl;
> return 1;
> } std::string schema_file = argv[1];
> std::ifstream ins(schema_file);
> avro::ValidSchema cpxSchema;
> avro::compileJsonSchema(ins, cpxSchema);
> } {code}
> 3. compile and run the cpp file with schema file as argument:
> {code:java}
> g++ -std=c++17 bug.cpp -o bug -I/usr/local/include -L/usr/local/lib -lavrocpp
> ./bug cpx.json{code}
> expected behavior: 0 return code
> observed behavior: 134 return code with output:
> {code:java}
> terminate called after throwing an instance of 'avro::Exception'
> what(): Invalid type. Expected "string" actual long
> Aborted {code}
>
>
> The same schema works in c, python, and java implementations as they don't
> require such keys to be string.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)