Bug: Cookie Expires labels a non-UTC aware datetime as GMT without converting it
メンテナーはふだん 1 日以内に返信
@LemonCondor がすでに取り組んでいます。
2026年10月29日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 86/100
調査の方向性
aws_lambda_powertools/shared/cookies.py の Cookie._format_date と、tests/unit/test_cookie_class.py で言及されている回帰テストから始めてください。そのテストを実行し、現在、フォーマット済みヘッダーでタイムゾーンオフセットが保持されることを確認してください。タイムゾーン付き datetime が UTC で出力され、naive datetime は現在の動作を維持し、回帰テストが成功すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Expected Behaviour
A Cookie whose expires is a timezone-aware datetime should send that instant in GMT, as RFC 6265 requires for Expires. datetime(2026, 1, 1, 12, tzinfo=timezone(timedelta(hours=2))) is 10:00 UTC, so the header should read Expires=Thu, 01 Jan 2026 10:00:00 GMT.
Current Behaviour
Cookie._format_date formats the datetime with strftime and a hard-coded GMT suffix, without converting it to UTC first. The local wall-clock time is labelled GMT, so the cookie expires earlier or later by the UTC offset: Expires=Thu, 01 Jan 2026 12:00:00 GMT.
Code snippet
from datetime import datetime, timedelta, timezone
from aws_lambda_powertools.shared.cookies import Cookie
cookie = Cookie("a", "b", expires=datetime(2026, 1, 1, 12, tzinfo=timezone(timedelta(hours=2))))
print(str(cookie)) # a=b; Secure; Expires=Thu, 01 Jan 2026 12:00:00 GMT
Possible Solution
Convert an aware datetime to UTC before formatting (expires.astimezone(timezone.utc)); naive datetimes keep today's behaviour. I have this fix with a regression test in tests/unit/test_cookie_class.py (fails on develop, passes with the change) and can open a PR once this is triaged.
Steps to Reproduce
Run the snippet above on develop (5785377).
Powertools for AWS Lambda (Python) version
latest (3.37.0, develop)
AWS Lambda function runtime
3.13
Packaging format used
PyPi
Debugging logs
N/A
- 主要言語
- 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 · コメント 4 件 · 担当者 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
-
area:scripts area:tests bug priority:later
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Ikalus1988/MisakaNet#4358 ·
メンテナーはふだん 1 日以内に返信
-
Discovered ports from service discovery are never propagated to modules in Module.load()対応中かも @vishalmore90 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
OWASP/Nettacker#1828 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
aws-samples/sample-per-model-bedrock#708 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
sjkim1127/Reversecore_MCP#365 ·
メンテナーはふだん 1 日以内に返信