Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core request id not override #19759

Merged
merged 3 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,12 @@ def on_request(self, request):
elif self._request_id is None:
return
elif self._request_id is not _Unset:
if "x-ms-client-request-id" in request.http_request.headers:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: update changelog

return
request_id = self._request_id
elif self._auto_request_id:
if "x-ms-client-request-id" in request.http_request.headers:
return
request_id = str(uuid.uuid1())
if request_id is not unset:
header = {"x-ms-client-request-id": request_id}
Expand Down
9 changes: 9 additions & 0 deletions sdk/core/azure-core/tests/test_request_id_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,12 @@ def test_request_id_policy(auto_request_id, request_id_init, request_id_set, req
assert request.headers["x-ms-client-request-id"] == "VALUE"
else:
assert not "x-ms-client-request-id" in request.headers

def test_request_id_already_exists():
"""Test policy with no other policy and happy path"""
request_id_policy = RequestIdPolicy()
request = HttpRequest('GET', 'http://127.0.0.1/')
request.headers["x-ms-client-request-id"] = "VALUE"
pipeline_request = PipelineRequest(request, PipelineContext(None))
request_id_policy.on_request(pipeline_request)
assert request.headers["x-ms-client-request-id"] == "VALUE"