Skip to content

Commit c1ad3d4

Browse files
authored
fix: Handled ctx=None for AvroDeserializer and ProtobufDeserializer in __call__ (confluentinc#1974)
1 parent 5f61d25 commit c1ad3d4

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Confluent's Python client for Apache Kafka
22

3+
## v2.10.1
4+
5+
v2.10.0 is a fix release with the following fixes
6+
7+
- Handled `None` value for optional `ctx` parameter in `ProtobufDeserializer` (#1939)
8+
- Handled `None` value for optional `ctx` parameter in `AvroDeserializer` (#1973)
9+
310
## v2.10.0
411

512
v2.10.0 is a feature release with the following fixes and enhancements:

src/confluent_kafka/schema_registry/avro.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ def __call__(self, data: bytes, ctx: Optional[SerializationContext] = None) -> U
557557
"message was not produced with a Confluent "
558558
"Schema Registry serializer".format(len(data)))
559559

560-
subject = self._subject_name_func(ctx, None)
560+
subject = self._subject_name_func(ctx, None) if ctx else None
561561
latest_schema = None
562562
if subject is not None:
563563
latest_schema = self._get_reader_schema(subject)
@@ -573,7 +573,7 @@ def __call__(self, data: bytes, ctx: Optional[SerializationContext] = None) -> U
573573
writer_schema = self._get_parsed_schema(writer_schema_raw)
574574

575575
if subject is None:
576-
subject = self._subject_name_func(ctx, writer_schema.get("name"))
576+
subject = self._subject_name_func(ctx, writer_schema.get("name")) if ctx else None
577577
if subject is not None:
578578
latest_schema = self._get_reader_schema(subject)
579579

src/confluent_kafka/schema_registry/protobuf.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -565,14 +565,15 @@ def __call__(self, message: Message, ctx: Optional[SerializationContext] = None)
565565
raise ValueError("message must be of type {} not {}"
566566
.format(self._msg_class, type(message)))
567567

568-
subject = self._subject_name_func(ctx,
569-
message.DESCRIPTOR.full_name)
570-
latest_schema = self._get_reader_schema(subject, fmt='serialized')
568+
subject = self._subject_name_func(ctx, message.DESCRIPTOR.full_name) if ctx else None
569+
latest_schema = None
570+
if subject is not None:
571+
latest_schema = self._get_reader_schema(subject, fmt='serialized')
572+
571573
if latest_schema is not None:
572574
self._schema_id = latest_schema.schema_id
573-
elif subject not in self._known_subjects:
574-
references = self._resolve_dependencies(
575-
ctx, message.DESCRIPTOR.file)
575+
elif subject not in self._known_subjects and ctx is not None:
576+
references = self._resolve_dependencies(ctx, message.DESCRIPTOR.file)
576577
self._schema = Schema(
577578
self._schema.schema_str,
578579
self._schema.schema_type,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy