diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b148fc02..a0338d1bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Confluent's Python client for Apache Kafka +## v2.10.1 + +v2.10.0 is a fix release with the following fixes + +- Handled `None` value for optional `ctx` parameter in `ProtobufDeserializer` (#1939) +- Handled `None` value for optional `ctx` parameter in `AvroDeserializer` (#1973) + ## v2.10.0 v2.10.0 is a feature release with the following fixes and enhancements: diff --git a/src/confluent_kafka/schema_registry/avro.py b/src/confluent_kafka/schema_registry/avro.py index 8f6cddf8b..368507752 100644 --- a/src/confluent_kafka/schema_registry/avro.py +++ b/src/confluent_kafka/schema_registry/avro.py @@ -557,7 +557,7 @@ def __call__(self, data: bytes, ctx: Optional[SerializationContext] = None) -> U "message was not produced with a Confluent " "Schema Registry serializer".format(len(data))) - subject = self._subject_name_func(ctx, None) + subject = self._subject_name_func(ctx, None) if ctx else None latest_schema = None if subject is not None: latest_schema = self._get_reader_schema(subject) @@ -573,7 +573,7 @@ def __call__(self, data: bytes, ctx: Optional[SerializationContext] = None) -> U writer_schema = self._get_parsed_schema(writer_schema_raw) if subject is None: - subject = self._subject_name_func(ctx, writer_schema.get("name")) + subject = self._subject_name_func(ctx, writer_schema.get("name")) if ctx else None if subject is not None: latest_schema = self._get_reader_schema(subject) diff --git a/src/confluent_kafka/schema_registry/protobuf.py b/src/confluent_kafka/schema_registry/protobuf.py index 39c2ce108..dfa5c1ffe 100644 --- a/src/confluent_kafka/schema_registry/protobuf.py +++ b/src/confluent_kafka/schema_registry/protobuf.py @@ -565,14 +565,15 @@ def __call__(self, message: Message, ctx: Optional[SerializationContext] = None) raise ValueError("message must be of type {} not {}" .format(self._msg_class, type(message))) - subject = self._subject_name_func(ctx, - message.DESCRIPTOR.full_name) - latest_schema = self._get_reader_schema(subject, fmt='serialized') + subject = self._subject_name_func(ctx, message.DESCRIPTOR.full_name) if ctx else None + latest_schema = None + if subject is not None: + latest_schema = self._get_reader_schema(subject, fmt='serialized') + if latest_schema is not None: self._schema_id = latest_schema.schema_id - elif subject not in self._known_subjects: - references = self._resolve_dependencies( - ctx, message.DESCRIPTOR.file) + elif subject not in self._known_subjects and ctx is not None: + references = self._resolve_dependencies(ctx, message.DESCRIPTOR.file) self._schema = Schema( self._schema.schema_str, self._schema.schema_type,