Skip to content

AttributeError when using None ctx in AvroDeserializer #2034

@yonathan-wolloch-lendbuzz

Description

when avro deserializer is called without (optional) parameter named ctx following Attribute Error is raised:

'NoneType' object has no attribute 'headers'

in here:

def avro_deserializer[VT: BaseModel](record: bytes) -> VT :
        """Deserialize a record using Avro schema.

        Args:
            record: The bytes to deserialize.

        Returns:
            dict[Any, Any]: The deserialized record as a dictionary.

        """
        deserializer = AvroDeserializer(schema_str='"bytes"', schema_registry_client=schema_registry_client)
        ctx = None 
        deserialized_record = deserializer(record, ctx)
        return model.model_validate_json(deserialized_record)

steps to reproduce:

schema_registry_client = SchemaRegistryClient(...)
local_schema = '"bytes"'
deserializer = AvroDeserializer(schema_registry_client, local_schema)
msg = deserializer(b'\x00\x00\x00\x10\x00\bar')

The exception is raised by confluent_kafka/schema_registry/init.py:187 in dual_schema_id_deserializer

Metadata

Metadata

Assignees

Labels

component:schema-registryAny schema registry related isues rather than kafka isolated ones

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions