Skip to content

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

Merged
leandrodamascena merged 3 commits into
aws-powertools:developfrom
chiruu12:fix/case-insensitive-dict-copy
Oct 16, 2026
Merged

leandrodamascena merged 3 commits 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
@boring-cyborg boring-cyborg Bot added the tests label Oct 16, 2026
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.92%. Comparing base (5524980) to head (661bf96).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8537   +/-   ##
========================================
  Coverage    96.91%   96.92%           
========================================
  Files          317      317           
  Lines        15959    15976   +17     
  Branches      1411     1413    +2     
========================================
+ Hits         15467    15484   +17     
  Misses         349      349           
  Partials       143      143           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud

Copy link
Copy Markdown

@leandrodamascena
leandrodamascena merged commit 66d3e3b into aws-powertools:develop Oct 16, 2026
14 checks passed
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. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants