Skip to content

Fix Encryption fails when referencing self defined types (#2254) - #2255

Merged
Robert Yokota (rayokota) merged 4 commits into
confluentinc:masterfrom
ChristophMajcenAtXxxlutz:fix/2254-encryption-when-referencing-types-in-schema
May 28, 2026
Merged

Robert Yokota (rayokota) merged 4 commits into
confluentinc:masterfrom
ChristophMajcenAtXxxlutz:fix/2254-encryption-when-referencing-types-in-schema

Conversation

@ChristophMajcenAtXxxlutz

Copy link
Copy Markdown
Contributor

What

Fix Encryption fails when referencing self defined types (#2254)

Checklist

  • Contains customer facing changes? Including API/behavior changes
  • Did you add sufficient unit test and/or integration test coverage for this PR?

References

Github:
#2254

Test & Review

Tested by automated tests

Copilot AI review requested due to automatic review settings May 27, 2026 14:17
@confluent-cla-assistant

confluent-cla-assistant Bot commented May 27, 2026 •

Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
✅ ChristophMajcenAtXxxlutz
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes encryption failures that occur when an Avro schema references a self-defined named type. The schema is now expanded via fastavro.schema.expand_schema before being passed to the field transformer so referenced types are resolved and tagged fields can be discovered for encryption.

Changes:

  • Call expand_schema on parsed/reader schemas before invoking transform in both sync and async Avro serializer/deserializer field transformers.
  • Add a test case (test_avro_encryption_complex_schema) in both the sync and async test suites covering encryption of a record that references a previously defined named type.
  • Update CHANGELOG.md with a fix entry referencing issue #2254.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/confluent_kafka/schema_registry/_sync/avro.py Imports expand_schema and wraps parsed_schema / reader_schema with it in the serializer and deserializer field transformers.
src/confluent_kafka/schema_registry/_async/avro.py Same change as sync variant, applied to async serializer and deserializer.
tests/schema_registry/_sync/test_avro_serdes.py Adds sync test verifying PII encryption works through a self-referenced record type.
tests/schema_registry/_async/test_avro_serdes.py Adds matching async test (also imports deepcopy).
CHANGELOG.md Adds bullet documenting the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rayokota

Copy link
Copy Markdown
Member

/sem-approve

@rayokota

Copy link
Copy Markdown
Member

ChristophMajcenAtXxxlutz , please run unasync as described here: https://github.com/confluentinc/confluent-kafka-python/blob/master/DEVELOPER.md#unasync--maintaining-sync-versions-of-async-code-schema-registry-only

@ChristophMajcenAtXxxlutz

Copy link
Copy Markdown
Contributor Author

@rayokota

Copy link
Copy Markdown
Member

/sem-approve

@rayokota

Copy link
Copy Markdown
Member

ChristophMajcenAtXxxlutz , the latest issue is:

Running mypy type checking ...02:12
src/confluent_kafka/schema_registry/_sync/avro.py:766: error:�(B Argument 1 has incompatible type �(B"str | list[Any] | dict[Any, Any] | None"�(B; expected �(B"str | list[Any] | dict[Any, Any]"�(B  �(B[arg-type]�(B02:17
src/confluent_kafka/schema_registry/_async/avro.py:775: error:�(B Argument 1 has incompatible type �(B"str | list[Any] | dict[Any, Any] | None"�(B; expected �(B"str | list[Any] | dict[Any, Any]"�(B  �(B[arg-type]�(B02:17
Found 2 errors in 2 files (checked 106 source files)�(B

@ChristophMajcenAtXxxlutz

Copy link
Copy Markdown
Contributor Author

ChristophMajcenAtXxxlutz , the latest issue is:

Running mypy type checking ...02:12
src/confluent_kafka/schema_registry/_sync/avro.py:766: error:�(B Argument 1 has incompatible type �(B"str | list[Any] | dict[Any, Any] | None"�(B; expected �(B"str | list[Any] | dict[Any, Any]"�(B  �(B[arg-type]�(B02:17
src/confluent_kafka/schema_registry/_async/avro.py:775: error:�(B Argument 1 has incompatible type �(B"str | list[Any] | dict[Any, Any] | None"�(B; expected �(B"str | list[Any] | dict[Any, Any]"�(B  �(B[arg-type]�(B02:17
Found 2 errors in 2 files (checked 106 source files)�(B

Fixed the mypi issue

@rayokota

Copy link
Copy Markdown
Member

/sem-approve

@rayokota Robert Yokota (rayokota) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ChristophMajcenAtXxxlutz , LGTM

@rayokota
Robert Yokota (rayokota) merged commit 3fd7408 into confluentinc:master May 28, 2026
2 checks passed
@ChristophMajcenAtXxxlutz
ChristophMajcenAtXxxlutz deleted the fix/2254-encryption-when-referencing-types-in-schema branch May 29, 2026 07:31
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.

3 participants