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.
Projectfastavro/fastavro
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
| 66 | 66 | if isinstance(writer_type, list) or isinstance(reader_type, list): | |
| 67 | 67 | return True | |
| 68 | 68 | 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 | |
| 70 | 73 | if writer_type == reader_type: | |
| 71 | 74 | return True | |
| 72 | 75 | # promotion cases | |
| ⋯ | |||
| 93 | 96 | # If the reader is a union, ensure one of the new schemas is the same | |
| 94 | 97 | # as the writer | |
| 95 | 98 | 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 | |
| 102 | 101 | else: | |
| 103 | 102 | raise SchemaResolutionError(error_msg) | |
| 104 | 103 | else: | |
The check that tells the two apart
fail→pass·tests/test_schema_evolution.py::test_union_of_lists_evolution_with_doc
fail→pass·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
- 2024-02-13Fix aliases in schema resolution (#751)
- 2023-05-04fix namespace handling
- 2022-09-09write_record
- 2022-07-29fix issue with decoding records within maps
- 2022-05-21fix bug where records should match but they were not
- 2021-12-22fix issue with json decoding of complex types within maps