Open
Description
Description
In the Message.__len__
method it gets the length of the value and returns that. Unfortunately, this means that if a user is using a DeserializingConsumer
that deserializes the value to a type that does not implement __len__
, then calling len(message)
fails with the following error:
TypeError: object of type 'SomeTypeWithoutLen' has no len()
This causes errors if you try to use a message in a truthy manner, such as
if message:
do_something()
or
actual_message = message or some_other_value
How to reproduce
- Create a topic
- Produce a message on the topic where the value is serialized using some avro schema
- Create a
DeserializingConsumer
with avalue.deserializer
that deserializes the message to a type that doesn't implement__len__
, such as a dataclass representing the avro record. This can be accomplished with thefrom_dict
attribute of theAvroDeserializer
. - Consume the message
message = consumer.poll()
- Call
len(message)
Checklist
Please provide the following information:
confluent-kafka-python: ('1.7.0', 17235968)
librdkafka: ('1.7.0', 17235968)
Metadata
Metadata
Assignees
Labels
Reporting an unexpected or problematic behavior of the codebaseIssues that are specific to C behavior or domain within the library independent of library logicMaintainer triage tag for indicating change required is particularly smallIssues that would especially appreciate external development or attention