Skip to content

Conversation

@gwallet
Copy link

@gwallet gwallet commented Sep 19, 2025

The Java JsonDecoder does not actually allow there to be unknown fields in the reader compared to the writer's schema. In cases where this happens it gives the following error: org.apache.avro.AvroTypeException: Expected Unknown fields: []. Got END_OBJECT

What is the purpose of the change

This pull request makes the JsonDecoder allow unknown fields in the reader, fixing AVRO-3106.

Verifying this change

This change is already covered by existing tests, such as TestEncoders#jsonExcessFields.
It has been adapted to reflect the change.

Documentation

  • Does this pull request introduce a new feature? no

The Java JsonDecoder does not actually allow there to be unknown fields in the reader compared to the writer's schema.
In cases where this happens it gives the following error:
org.apache.avro.AvroTypeException: Expected Unknown fields: [<field name redacted>]. Got END_OBJECT
@github-actions github-actions bot added the Java Pull Requests for Java binding label Sep 19, 2025
@RyanSkraba
Copy link
Contributor

Hello! Thanks for your contribution -- I just want to clarify: the JsonDecoder does work if the writer schema and the reader schema are both present right? The test case only shows the reader schema.

@gwallet
Copy link
Author

gwallet commented Dec 24, 2025

Hi!

The JsonDecoder is currently failing when a property is present in the JSON document that is not advertised by the reader schema.

It means that if a document producer send document relying on a new schema version which is backward compatible with the previous version (a new property/field), actual consumer that have not been updated can't read the document (at least the known properties advertised by the old document version schema).

That's why the testcase only shows the reader schema, because it is the relevant one that shows the 'old' version that should be able to read document with unknown properties, according to the statement:

if the writer's record contains a field with a name not present in the reader's record, the writer's value for that field is ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Pull Requests for Java binding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants