You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: copying or merging CaseInsensitiveDict (event.headers) loses case-insensitive lookup #8536
A copy or merge of event.headers should still be a CaseInsensitiveDict, so that headers.copy().get("Content-Type") and (headers | {"X-Trace-Id": "1"})["x-trace-id"] work the same way they do on event.headers itself.
Current Behaviour
CaseInsensitiveDict overrides get, update, __getitem__ and friends, but not copy, __or__, __ror__ or __ior__, so those fall through to dict:
copy() and | return a plain dict. The stored keys are already lowercased, so looking up the original header name on the result returns None.
|= goes through dict's own update path rather than the overridden update, so the new key keeps its case and a lowercase lookup misses it.
This came up after #8517: a handler that copies the headers to add one before forwarding them loses the case-insensitive lookup on the copy.
Override copy, __or__, __ror__ and __ior__ on CaseInsensitiveDict so they return a CaseInsensitiveDict and route through update. Happy to open a PR with tests.
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Activity
powertools-for-aws-oss-automation commentedon Oct 16, 2026
Warning
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
github-actions commentedon Oct 22, 2026
This is now released under 3.37.0 version!