Bug: SQSMessageAttribute.binary_value raises KeyError for String attributes
メンテナーはふだん 1 日以内に返信
評価
この issue はまだ評価されていません。
説明
Expected Behaviour
SQSMessageAttribute.string_value and binary_value are typed str | None, so reading the value an attribute doesn't carry should return None.
Current Behaviour
Both properties index the dict directly (self["stringValue"], self["binaryValue"]). Lambda only sends the field that matches the attribute's type; the SQS example event in the Lambda docs has {"stringValue": "myValue", "stringListValues": [], "binaryListValues": [], "dataType": "String"} with no binaryValue. So binary_value on any String or Number attribute, and string_value on any Binary attribute, raise KeyError.
The test event tests/events/sqsEvent.json puts both stringValue and binaryValue on one attribute, which is why the existing tests don't hit this. The Pydantic SqsMsgAttributeModel already declares both fields optional.
Code snippet
from aws_lambda_powertools.utilities.data_classes import SQSEvent
event = {"Records": [{
"messageId": "1", "receiptHandle": "r", "body": "b", "attributes": {}, "md5OfBody": "m",
"eventSource": "aws:sqs", "eventSourceARN": "arn:aws:sqs:us-east-2:123456789012:q", "awsRegion": "us-east-2",
"messageAttributes": {
"text": {"stringValue": "myValue", "stringListValues": [], "binaryListValues": [], "dataType": "String"},
},
}]}
record = next(SQSEvent(event).records)
record.message_attributes["text"].binary_value # KeyError: 'binaryValue'
Steps to Reproduce
- Send an SQS message with a String message attribute to a Lambda function.
- Read
binary_valueon that attribute (orstring_valueon a Binary one). KeyErroris raised instead ofNone.
Possible Solution
Use self.get(...) in both properties. I can open a PR.
Powertools for AWS Lambda (Python) version
latest (develop, 3.38.0)
AWS Lambda function runtime
3.12
Packaging format used
PyPi
Debugging logs
No response
- 主要言語
- Python
- スター
- 3.3k
- フォーク
- 511
- 平均マージ
- 3日 8時間
- マージ済み PR(30日)
- 92
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws-powertools/powertools-lambda-python のほかの issue
-
Bug: POWERTOOLS_IDEMPOTENCY_DISABLED set to an empty or non-boolean value crashes every invocation対応中かも @lechakrawarthy が 1 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
aws-powertools/powertools-lambda-python#8728 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: Redis layer fails the invocation instead of retrying when a record expires between SET NX and GET対応中かも @coughlmao が 1 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
aws-powertools/powertools-lambda-python#8727 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: Redis orphan lock timeout ignores expires_after_seconds and is always 10 seconds対応中かも @CJstate が 1 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
aws-powertools/powertools-lambda-python#8726 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: idempotency payloads with set, frozenset or bytes fields cannot be hashed対応中かも @Neeraj111010 が 1 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
aws-powertools/powertools-lambda-python#8725 · コメント 6 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Bug: with a DynamoDB composite key, DataRecord.idempotency_key is the static partition key value対応中かも @sumedh-aerram が 1 日前に担当しました。 オープンbug good first issue help wanted idempotency
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
aws-powertools/powertools-lambda-python#8724 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
aws-powertools/powertools-lambda-python の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
aws/sagemaker-python-sdk#6554 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
huggingface/diffusers#15170 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] LLM conflict check ignores MNEMOSYNE_LLM_MAX_TOKENS, so reasoning models return empty repliesオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
mnemosyne-oss/mnemosyne#1325 ·
メンテナーはふだん 1 日以内に返信
-
enhancement meshtastic-2.8
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
pskillen/meshflow-api#459 ·