Bug: Cookie with SameSite.DEFAULT_MODE sends an empty SameSite= attribute

Đang mở
#8,708 1 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@anishmehta24 đang làm issue này rồi.

Từ ngày 30/10/2026.

  • #8709 của @anishmehta24 — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug event_handlers

Expected Behaviour

Cookie(..., same_site=SameSite.DEFAULT_MODE) leaves the SameSite attribute out of the Set-Cookie header, so the browser applies its default (the same as Go's http.SameSiteDefaultMode, which these names follow).

Current Behaviour

Cookie.__str__ checks if self.same_site:, which is true for every enum member, and DEFAULT_MODE has the value "", so the header gets an attribute with no value: SameSite=. That is not a valid SameSite value.

Code snippet

from aws_lambda_powertools.shared.cookies import Cookie, SameSite

str(Cookie(name="session", value="abc", same_site=SameSite.DEFAULT_MODE))
# 'session=abc; Secure; SameSite='

Steps to Reproduce

  1. Create a Cookie with same_site=SameSite.DEFAULT_MODE.
  2. Return it in a Response(cookies=[...]) or call str() on it.
  3. The Set-Cookie value ends with SameSite=.

Possible Solution

Only write the attribute when the enum value is not empty. 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

Ngôn ngữ chính
Python
Star
3.3k
Fork
511
Merge trung bình
3 ngày 12 giờ
Pull request đã merge (30 ngày)
93

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của aws-powertools/powertools-lambda-python

Tất cả issue của aws-powertools/powertools-lambda-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.