Repository navigation
fix(event_handler): send cookie Expires in GMT with English day and month names - #8876
Open
cleissonom wants to merge 1 commit into
Open
cleissonom wants to merge 1 commit into
cleissonom wants to merge 1 commit into
Conversation
|
Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need. |
…onth names A timezone-aware expires was formatted as its local wall-clock time with a GMT suffix, so the cookie expired early or late by the UTC offset. strftime's %a and %b also followed the process LC_TIME locale, producing names browsers cannot parse. Convert aware datetimes to UTC and format with email.utils.format_datetime. Naive datetimes keep being read as UTC and a date keeps meaning midnight GMT. An instant outside years 1 to 9999 is clamped instead of raising OverflowError.
cleissonom
force-pushed
the
fix/cookie-expires-utc
branch
from
November 19, 2026 15:12
805ef99 to
30615f4
Compare
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Issue number:
closes #8671
Summary
Changes
Cookieformats expiry dates withstrftimeand a fixedGMTsuffix. For a non-UTC datetime, that changes the intended expiry time by its UTC offset. The day and month names also depend onLC_TIME, so a non-English locale can produce an invalid cookie date._format_datenow converts the value to UTC and usesemail.utils.format_datetime(..., usegmt=True). This fixes both problems discussed in #8671. The import stays inside the function so its cost is deferred until an expiry value is formatted.Naive datetimes still mean UTC, and
datevalues still mean midnight GMT. UTC conversions outside years 1 to 9999 are clamped to the nearest representable boundary to avoid introducingOverflowError. The constructor docstring explains the timezone handling.User experience
datetime(2026, 1, 1, 12, tzinfo=timezone(timedelta(hours=2)))Expires=Thu, 01 Jan 2026 12:00:00 GMTExpires=Thu, 01 Jan 2026 10:00:00 GMTdatetime(2026, 10, 30, 7, 28)withLC_TIME=de_DE.UTF-8Expires=Fr., 30 Okt. 2026 07:28:00 GMTExpires=Fri, 30 Oct 2026 07:28:00 GMTThe cookie payload shape is unchanged. The date text changes without a deprecation warning under ADR 0006: the previous output contradicted the RFC 6265 cookie date format, and the maintainer confirmed both fixes in the issue.
Verification
I used an AI coding assistant.
I ran
uv run --locked pytest tests/unit/test_cookie_class.py tests/functional/event_handler/required_dependencies/test_api_gateway.py -q -k cookieon this commit, withcookies.pytaken fromdevelop(4 failed, 16 passed) and with the change (20 passed), and read both outputs.The added tests cover timezone conversion, locale-independent formatting,
datevalues, range boundaries, and cookie output throughAPIGatewayRestResolverandAPIGatewayHttpResolver. The locale unit test uses adatetimesubclass to emulate Germanstrftimeoutput, following #8707, so it does not depend on installed locales.Other recorded checks on macOS arm64, with locked dependencies and base
a2eb4d59:OverflowErrorif conversion is added without the clamp.test_channel_path_normalizationskip.make pron Python 3.14.6: 4,241 passed, 73 skipped and 0 failed; 10 performance tests passed. Mypy and bandit pass,cookies.pyremains at xenon rank A, and generated skill references are unchanged.date, microsecond and boundary outputs. Non-UTC values, including year rollover,Europe/BerlinandAmerica/Sao_Paulo, get the corrected GMT time. Realde_DE,fr_FRandja_JPlocale checks produce English names.These checks were local. The change has not been run against a real API Gateway, ALB or Function URL, and no AWS resources were used.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.