Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.12.0, 1.11.2
-
None
-
None
-
Python 3.10.3
avro 1.11 and 1.12
Description
The following script raises a validation exception because the map schema .validate doesn't check the value types, so union schema picks the wrong path, and then raises:
from io import BytesIO import json import avro.io import avro.schema SCHEMA = [ {"type": "map", "values": "int"}, { "type": "record", "name": "A", "fields": [ {"aliases": [], "type": "string", "name": "x"}, ], }, ] datum = {'x': 'Hello'} if __name__ == '__main__': sch = avro.schema.parse(json.dumps(SCHEMA)) buf = BytesIO() encoder = avro.io.BinaryEncoder(buf) writer = avro.io.DatumWriter(sch) encoded = writer.write(datum, encoder)