Skip to content

[azure-core] Keep CaseInsensitiveSet consistent for in-place set operations - #49608

Open
Sebastian Turner (auraseb) wants to merge 1 commit into
Azure:mainfrom
auraseb:fix/caseinsensitiveset-inplace-ops
Open

Sebastian Turner (auraseb) wants to merge 1 commit into
Azure:mainfrom
auraseb:fix/caseinsensitiveset-inplace-ops

Conversation

@auraseb

Copy link
Copy Markdown

Description

CaseInsensitiveSet (used for HttpLoggingPolicy.allowed_header_names and the allowed_query_params sets of HttpLoggingPolicy and DistributedTracingPolicy) subclasses set and answers in from a separate lowercase cache. The inherited |=, -=, &=, ^=, difference_update, intersection_update and symmetric_difference_update modify the base set without updating that cache, so policy.allowed_header_names |= {"x-custom-header"} leaves the header redacted and policy.allowed_header_names -= {"x-ms-request-id"} leaves it logged. Both worked while these attributes were plain sets.

This change overrides those methods so they go through add and discard, which keep the cache in sync. Matching is case-insensitive, consistent with the existing discard and remove. The in-place operators return NotImplemented for non-set operands, matching the built-in set.

Tests added in tests/test_utils.py for each operation, and in tests/test_http_logging_policy.py for the user-facing logging behavior. A CHANGELOG entry is added under Bugs Fixed.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Fixes #49607

Copilot AI balanced review requested due to automatic review settings October 19, 2026 19:05
@github-actions github-actions Bot added Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution Sebastian Turner (@auraseb)! We will review the pull request and get back to you soon.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
5 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Self-subtraction raises during iteration and can leave allowlists only partially cleared.

1 open issue
What changed in this PR

Fixes #49607 by keeping CaseInsensitiveSet membership checks consistent with in-place mutations used by logging and tracing allowlists.

Changes:

  • Routes in-place operators and update methods through cache-aware mutations.
  • Adds utility and logging regression tests.
  • Documents the fix in the changelog.
File Description
sdk/​core/​azure-core/​tests/​test_utils.py Tests case-insensitive set mutations.
sdk/​core/​azure-core/​tests/​test_http_logging_policy.py Tests header redaction after allowlist changes.
sdk/​core/​azure-core/​CHANGELOG.md Documents the allowlist fix.
sdk/​core/​azure-core/​azure/​core/​utils/​_utils.py Adds cache-aware mutation overrides.

Review effort: Balanced


def difference_update(self, *others):
for other in others:
for item in other:
…ations

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 19, 2026 20:59
@auraseb
Sebastian Turner (auraseb) force-pushed the fix/caseinsensitiveset-inplace-ops branch from 4aa6bd1 to 166f9f4 Compare October 19, 2026 20:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Self-subtraction still raises an iteration error instead of clearing the set.

1 open issue

Review effort: Balanced

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

Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[azure-core] In-place set operators on HttpLoggingPolicy.allowed_header_names are silently ignored

2 participants