You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: ConsumerRecordRecords.key returns None when record key is an empty string #8696
When a Kafka event contains an empty key ("key": ""), ConsumerRecordRecords.key should deserialize the empty string and return an empty key (e.g. "" or b""), matching Kafka semantics and KafkaEventRecord.decoded_key behavior. Only missing or null keys (None) should evaluate to None.
Current Behaviour
In aws_lambda_powertools/utilities/kafka/consumer_records.py (line 35):
key=self.get("key")
# Return None if key doesn't existifnotkey:
returnNone
Because if not key: performs a truthiness check rather than an identity check against None, any empty base64 string ("key": "") is treated as nonexistent and returns None.
In contrast, KafkaEventRecord.decoded_key in aws_lambda_powertools.utilities.data_classes.kafka_event correctly distinguishes between missing and empty keys:
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
powertools-for-aws-oss-automation commented on Oct 28, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out our GitHub Discussions: Join the conversation
Thanks @ASHMEET555, confirmed: a record whose key is an empty string comes back as key=None, so a consumer can't tell "no key" from "empty key". It's yours, I'll review #8698. This goes into 3.40.0.
Activity
boring-cyborg commentedon Oct 28, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link
powertools-for-aws-oss-automation commentedon Oct 28, 2026
Thanks for opening your first issue here! We'll come back to you as soon as we can.
In the meantime, check out our GitHub Discussions: Join the conversation
leandrodamascena commentedon Oct 29, 2026
Thanks @ASHMEET555, confirmed: a record whose key is an empty string comes back as
key=None, so a consumer can't tell "no key" from "empty key". It's yours, I'll review #8698. This goes into 3.40.0.