Skip to content

fix(data-classes): keep CaseInsensitiveDict on copy and merge - #8537

Open
chiruu12 wants to merge 1 commit into
aws-powertools:developfrom
chiruu12:fix/case-insensitive-dict-copy
Open

chiruu12 wants to merge 1 commit into
aws-powertools:developfrom
chiruu12:fix/case-insensitive-dict-copy

Conversation

@chiruu12

@chiruu12 chiruu12 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Issue number: closes #8536

Summary

Changes

CaseInsensitiveDict now overrides copy, __or__, __ror__ and __ior__. copy, | and the reflected | return a CaseInsensitiveDict, and all of them go through the existing update, so new keys are lowercased the same way as everywhere else.

Two tests added to tests/unit/data_classes/required_dependencies/test_common.py. Both fail on develop and pass with the change.

User experience

Before, event.headers.copy().get("Content-Type") returned None, headers | {...} gave back a plain dict, and headers |= {"X-Trace-Id": "1"} stored X-Trace-Id without lowercasing it.

After, a copy or merge of event.headers keeps case-insensitive lookup.


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.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 16:01
@chiruu12
chiruu12 requested a review from a team as a code owner October 6, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 6, 2026
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: copying or merging CaseInsensitiveDict (event.headers) loses case-insensitive lookup

2 participants