I'm trying to decode an OCF with invalid values for the namespace:
{"type":"record","name":"null","namespace":"null","fields":[{"name":"partition","type":"int"}, // [...]
Despite the namespace, erlavro would be able to decode it correctly except for a sanity check in avro_utils:579:
?ERROR_IF(lists:member(CanonicalName, ReservedNames),
{reserved, Name, CanonicalName}).
Which produces:
** (ErlangError) Erlang error: {:reserved, "null", "null"}
code: :avro_ocf.decode_file("redacted file path")
stacktrace:
src/avro_util.erl:579: :avro_util.verify_type_name/1
src/avro_record.erl:90: :avro_record.type/3
src/avro_json_decoder.erl:72: :avro_json_decoder.decode_schema/2
src/avro_ocf.erl:77: :avro_ocf.decode_binary/1
test/avro_archive_file_test.exs:14: (test)
Should that verification be here when deserializing existing data ? Even if "null" is not a value accepted by the spec, erlavro works fine if we bypass that check; it is able to read the OCF file correctly.
I don't know the code base enough to understand if it makes sense from that point of view. From a user of the lib's point of view, on the other hand, it seems regrettable to prevent erlavro from being able to decode a file correctly when it's capable of doing it, if you see what I mean. Maybe there could be a "strict mode" option ?
If relevant, we are ready to work on a PR to improve the situation.
I'm trying to decode an OCF with invalid values for the namespace:
Despite the namespace, erlavro would be able to decode it correctly except for a sanity check in avro_utils:579:
Which produces:
Should that verification be here when deserializing existing data ? Even if "null" is not a value accepted by the spec, erlavro works fine if we bypass that check; it is able to read the OCF file correctly.
I don't know the code base enough to understand if it makes sense from that point of view. From a user of the lib's point of view, on the other hand, it seems regrettable to prevent erlavro from being able to decode a file correctly when it's capable of doing it, if you see what I mean. Maybe there could be a "strict mode" option ?
If relevant, we are ready to work on a PR to improve the situation.