Skip to content

Fix Encryption fails when expanded union types have two references to the same record (#2262)#2263

Merged
Robert Yokota (rayokota) merged 5 commits into
confluentinc:masterfrom
ChristophMajcenAtXxxlutz:fix/2262-Encryption-fails-when-expanded-union-types-have-two-references-to-the-same-record
Jun 5, 2026
Merged

Fix Encryption fails when expanded union types have two references to the same record (#2262)#2263
Robert Yokota (rayokota) merged 5 commits into
confluentinc:masterfrom
ChristophMajcenAtXxxlutz:fix/2262-Encryption-fails-when-expanded-union-types-have-two-references-to-the-same-record

Conversation

@ChristophMajcenAtXxxlutz
Copy link
Copy Markdown
Contributor

@ChristophMajcenAtXxxlutz ChristophMajcenAtXxxlutz commented Jun 2, 2026

What

Fix Encryption fails when expanded union types have two references to the same record

Checklist

  • Contains customer facing changes? Including API/behavior changes
  • Did you add sufficient unit test and/or integration test coverage for this PR?
    • If not, please explain why it is not required

References

Github: #2262

Test & Review

Automatic tests

Copilot AI review requested due to automatic review settings June 2, 2026 11:59
@confluent-cla-assistant
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.

Copy link
Copy Markdown

Copilot AI left a comment

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 an issue where encryption fails when expanded union types contain two references to the same record. Adds a _collapse_schema helper that re-collapses already-expanded named type references before validation in _resolve_union.

Changes:

  • Add _collapse_schema function to collapse expanded named-type references back to name references before validating union members.
  • Use _collapse_schema on a deep copy of the subschema in _resolve_union prior to validate().
  • Add sync and async tests covering union with two references to the same record type, plus a CHANGELOG entry.

Reviewed changes

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

File Description
src/confluent_kafka/schema_registry/common/avro.py Adds _collapse_schema helper and uses it during union resolution validation.
tests/schema_registry/_sync/test_avro_serdes.py Adds sync test for encryption with union containing repeated record refs.
tests/schema_registry/_async/test_avro_serdes.py Adds async equivalent test.
CHANGELOG.md Documents the fix.

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

Comment thread src/confluent_kafka/schema_registry/common/avro.py Outdated
Comment thread src/confluent_kafka/schema_registry/common/avro.py Outdated
Comment thread src/confluent_kafka/schema_registry/common/avro.py Outdated
Comment thread src/confluent_kafka/schema_registry/common/avro.py Outdated
Comment thread src/confluent_kafka/schema_registry/common/avro.py
Comment thread src/confluent_kafka/schema_registry/common/avro.py Outdated
Comment thread tests/schema_registry/_sync/test_avro_serdes.py
Comment thread tests/schema_registry/_sync/test_avro_serdes.py
@rayokota
Copy link
Copy Markdown
Member

/sem-approve

@rayokota
Copy link
Copy Markdown
Member

ChristophMajcenAtXxxlutz , please run make style-fix

@ChristophMajcenAtXxxlutz ChristophMajcenAtXxxlutz force-pushed the fix/2262-Encryption-fails-when-expanded-union-types-have-two-references-to-the-same-record branch from e2772a8 to af67577 Compare June 3, 2026 08:53
@ChristophMajcenAtXxxlutz
Copy link
Copy Markdown
Contributor Author

Robert Yokota (@rayokota) Fixed the styling issues

@rayokota
Copy link
Copy Markdown
Member

/sem-approve

@rayokota
Copy link
Copy Markdown
Member

ChristophMajcenAtXxxlutz , looks like there's a mypy error now:

Running mypy type checking ...02:08
src/confluent_kafka/schema_registry/common/avro.py:270: error:�(B Unsupported right operand type for in (�(B"Any | None"�(B) �(B[operator]�(B02:12
Found 1 error in 1 file (checked 106 source files)�(B

@rayokota
Copy link
Copy Markdown
Member

/sem-approve

Copy link
Copy Markdown
Member

@rayokota Robert Yokota (rayokota) left a comment

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 f9deec4 into confluentinc:master Jun 5, 2026
2 checks passed
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