Skip to content

Commit 191b2f1

Browse files
authored
[Identity] Add RequestIdPolicy to default pipeline policies (#46070)
Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
1 parent cce72b4 commit 191b2f1

4 files changed

Lines changed: 6 additions & 0 deletions

File tree

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
### Other Changes
1212

13+
- Added `RequestIdPolicy` to the default pipeline policies to ensure a unique `x-ms-client-request-id` header is sent with each request. ([#46070](https://github.com/Azure/azure-sdk-for-python/pull/46070))
14+
1315
## 1.25.3 (2026-03-12)
1416

1517
### Bugs Fixed

sdk/identity/azure-identity/azure/identity/_internal/pipeline.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
HeadersPolicy,
1212
NetworkTraceLoggingPolicy,
1313
ProxyPolicy,
14+
RequestIdPolicy,
1415
RetryPolicy,
1516
UserAgentPolicy,
1617
HttpLoggingPolicy,
@@ -38,6 +39,7 @@ def _get_config(**kwargs) -> Configuration:
3839

3940
def _get_policies(config, _per_retry_policies=None, **kwargs):
4041
policies = [
42+
RequestIdPolicy(**kwargs),
4143
config.headers_policy,
4244
config.user_agent_policy,
4345
config.proxy_policy,

sdk/identity/azure-identity/tests/test_aad_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def send(request, **_):
120120
assert actual.scheme == "https"
121121
assert actual.netloc == expected_netloc
122122
assert actual.path.startswith("/" + tenant_id)
123+
assert "x-ms-client-request-id" in request.headers
123124
return mock_response(json_payload={"token_type": "Bearer", "expires_in": 42, "access_token": "***"})
124125

125126
client = AadClient(tenant_id, "client id", transport=Mock(send=send), authority=authority)

sdk/identity/azure-identity/tests/test_aad_client_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ async def send(request, **_):
172172
assert actual.scheme == "https"
173173
assert actual.netloc == expected_netloc
174174
assert actual.path.startswith("/" + tenant_id)
175+
assert "x-ms-client-request-id" in request.headers
175176
return mock_response(json_payload={"token_type": "Bearer", "expires_in": 42, "access_token": "***"})
176177

177178
client = AadClient(tenant_id, "client id", transport=Mock(send=send), authority=authority)

0 commit comments

Comments
 (0)