Skip to content

AVRO-3803: [python] Fix remaining ipc and schema bugs - #4079

Open
kojiromike wants to merge 1 commit into
apache:mainfrom
kojiromike:avro-3803
Open

kojiromike wants to merge 1 commit into
apache:mainfrom
kojiromike:avro-3803

Conversation

@kojiromike

@kojiromike kojiromike commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What is the purpose of the change

This fixes the two AVRO-3803 bugs still on main. It supersedes #2319 by @asosnovsky, which found them. Its other two fixes are already on main, one of them via #3710.

  • Responder.respond() lost errors raised after the handshake, including responses that don't match their schema. The requestor saw InvalidAvroBinaryEncoding instead of the server's error.
  • Types nested in an "error" schema lost the error's namespace.

Out of scope: if the handshake itself fails (for example, the client's protocol does not parse), the reply still has no handshake, so the client cannot read it. Java behaves the same way, and the spec has no way to report a handshake error, so fixing that needs a spec decision first.

Verifying this change

Added tests cover the following scenarios:

  • A loopback round trip including the first handshake.
  • A system error reaching the requestor.
  • A response that doesn't match its schema reaching the requestor as an error.
  • A FramedReader empty reader from AVRO-3803: Python patched up ipc issues #2319.
  • The error namespace.

The bug tests fail on main without the fix. The full lang/py suite, ruff, and mypy pass locally.

Documentation

This introduces no new feature.

This fixes the two avro.ipc and schema bugs from AVRO-3803 that are
still on main. apache#2319 found them but has conflicts and has gone stale,
and the bytes compare part already landed in apache#3710. This is based on
apache#2319 by Ari Sosnovsky.

In Responder.respond(), when an AvroException is raised after the
handshake for an unreadable request, an unknown message, or a response
that does not match its schema, the error was written to a throwaway
BytesIO and the stale buffer returned, so the requestor got a decode
error (InvalidAvroBinaryEncoding) instead of the server's error. Now it
keeps the handshake response and replaces whatever followed it with the
system error. Also, RecordSchema set the default namespace for nested
types only when the type was "record", so types defined inside an
"error" lost the error's namespace.

The new tests are in-memory loopback requestor and responder tests for a
full round trip including the first-contact handshake, for a system
error reaching the requestor, and for a response that does not match its
schema reaching the requestor as an error. They also include the
empty-reader FramedReader test from apache#2319 and a schema test for error
namespaces. The bug tests fail without the fix.

Co-authored-by: Ari Sosnovsky <asosnovsky@users.noreply.github.com>
Generated-by: Claude Code 2.1.314 (Claude Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant