Expected Behaviour
The properties for offset and partition are the correct int type on the KafkaEventRecord class.
Current Behaviour
The properties for offset and partition on the KafkaEventRecord are currently defined as str type.
Code snippet
class KafkaEventRecord(DictWrapper):
@property
def topic(self) -> str:
"""The Kafka topic."""
return self["topic"]
@property
def partition(self) -> str:
"""The Kafka record parition."""
return self["partition"]
@property
def offset(self) -> str:
"""The Kafka record offset."""
return self["offset"]
https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/data_classes/kafka_event.py#L18
Possible Solution
Change the type to int for the partition and offset properties on the KafkaEventRecord class.
Steps to Reproduce
from aws_lambda_powertools.utilities.data_classes import event_source, KafkaEvent
@event_source(data_class=KafkaEvent)
def lambda_handler(event: KafkaEvent, context):
assert isinstance(event.record.offset, int)
assert isinstance(event.record.partition, int)
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
Lambda Layers
Debugging logs
No response
Expected Behaviour
The properties for
offsetandpartitionare the correctinttype on theKafkaEventRecordclass.Current Behaviour
The properties for
offsetandpartitionon theKafkaEventRecordare currently defined asstrtype.Code snippet
https://github.com/aws-powertools/powertools-lambda-python/blob/develop/aws_lambda_powertools/utilities/data_classes/kafka_event.py#L18
Possible Solution
Change the type to
intfor thepartitionandoffsetproperties on theKafkaEventRecordclass.Steps to Reproduce
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
Lambda Layers
Debugging logs
No response