Whole file

fastavro/fastavro

The author described this change as fix bug with schema evolution in unions. It counts as a record because the checks below fail on the code as it stood at 0e1c55ceb and pass on e85aa6e93, with nothing else changed between the two runs.

Fix saved2020-12-02
Sharing licenceMIT · LICENSE
Change size+6 7

What the code was meant to do, written into the code itself as a save note

fix bug with schema evolution in unions

The change

6666 if isinstance(writer_type, list) or isinstance(reader_type, list):
6767 return True
6868 if isinstance(writer_type, dict) or isinstance(reader_type, dict):
69- return match_schemas(writer_type, reader_type)
69+ try:
70+ return match_schemas(writer_type, reader_type)
71+ except SchemaResolutionError:
72+ return False
7073 if writer_type == reader_type:
7174 return True
7275 # promotion cases
9396 # If the reader is a union, ensure one of the new schemas is the same
9497 # as the writer
9598 for schema in r_schema:
96- try:
97- if match_types(w_schema, schema):
98- return schema
99- except SchemaResolutionError:
100- # Try to match the next schema in the union
101- pass
99+ if match_types(w_schema, schema):
100+ return schema
102101 else:
103102 raise SchemaResolutionError(error_msg)
104103 else:

The check that tells the two apart

failpass·tests/test_schema_evolution.py::test_union_of_lists_evolution_with_doc
failpass·tests/test_schema_evolution.py::test_union_of_lists_evolution_with_extra_type

Check file tests/test_schema_evolution.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it0e1c55ceb9d001b69bebca6f8ed75f241beb254c
Broken version dated2020-11-26
Modulefastavro._read_py
Units changedmatch_schemas, match_types
Fingerprint49950972593b7445
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in fastavro/fastavro