Skip to content

Fix reading records when additional fields exist and should be skipped - #179

Merged
AdrianStrugala merged 2 commits into
AdrianStrugala:masterfrom
robertcoltheart:bug/fix-reading-additional-fields
Jul 14, 2026
Merged

Fix reading records when additional fields exist and should be skipped#179
AdrianStrugala merged 2 commits into
AdrianStrugala:masterfrom
robertcoltheart:bug/fix-reading-additional-fields

Conversation

@robertcoltheart

@robertcoltheart robertcoltheart commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Fixes: #151 (possibly)

Not sure if this fixes the above issue, but we encountered exactly this error recently.

Setup

We have a write schema which has an additional field in an array schema. This field has been added in the middle of the other fields, which is a valid Avro schema change. The array has multiple items in it. Our read schema does not have this field, and we expect the field to be skipped correctly.

Behavior observed

The first array item to be read is processed correctly, and the read steps are cached. However the 2nd read, which uses those cached steps, aborts on the first occurrence of a "skipped" field, and leaves the rest of the byte stream for the array item untouched. A subsequent read of any field results in incorrectly parsed values and exceptions. In our case we saw stack overflow, but also saw other "bad format" etc exceptions as well.

Fix

The fix is to continue reading the fields when a "skipped" field is encountered. This is already the behavior for 'first reads' of an object, this just mirrors the behavior for the cached steps as well. I've also added a very specific unit test which tests this behavior.

@robertcoltheart

Copy link
Copy Markdown
Contributor Author

@AdrianStrugala Appreciate if you can take a look at this, as we are currently experiencing issues with this in our systems. Thanks!

@robertcoltheart

Copy link
Copy Markdown
Contributor Author

Hi @AdrianStrugala sorry to ping you but we'd really like to get this resolved in case we have other mismatched schemas like this in our systems. Any chance you can expedite this one?

@AdrianStrugala
AdrianStrugala merged commit 1a415be into AdrianStrugala:master Jul 14, 2026
1 check passed
@AdrianStrugala

Copy link
Copy Markdown
Owner

Hello @robertcoltheart, I have just merged your PR and released a new version

@robertcoltheart
robertcoltheart deleted the bug/fix-reading-additional-fields branch July 14, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Attempt to deserialise incorrectly formatted stream causes stack overflow error

2 participants