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

Aberta
#8,708 1 comentário 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@anishmehta24 já está trabalhando nisso.

Desde 30/10/2026.

  • #8709 de @anishmehta24 — aberto

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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

Linguagem predominante
Python
Estrelas
3.3k
Forks
511
Merge médio
3d 8h
PRs com merge (30d)
92

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de aws-powertools/powertools-lambda-python

Todas as issues de aws-powertools/powertools-lambda-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.