Repository navigation
fix(http): improve parameters name decoding precision and span lifecycle - #822
Conversation
|
Hi Vincent Biret (@baywet)! This PR refines |
|
I have updated the PR to address the feedback regarding span lifecycle coverage:
The PR is ready for review. Thank you! |
|
I have addressed the review comment in commit 6d506cb.
All formatting, lint checks, static type checks ( |
Vincent Biret (baywet)
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
…n and null checks
6d506cb to
4689c5e
Compare
Head branch was pushed to by a user without write access
|




Summary
In
ParametersNameDecodingHandler(microsoft-kiota-http), there were four issues in parameter decoding, URL manipulation, and telemetry:decode_uri_encoded_stringdecoded parameters by callingoriginal.replace(parameter, new_parameter)on the whole query string. If a query parameter's value happened to contain an encoded parameter name (e.g.,query=%24select&$select=1), the value was erroneously decoded (query=$select), corrupting query parameter values.f"%{ord(x):X}"), failing to decode standard lowercase percent-encoding (such as%2d,%2e,%7e).original_url.replace(query_params, decoded_query_parameters_string)replaced the first occurrence in the entire URL, corrupting paths that contain identical substrings. Replacing query viarequest.url.copy_with(query=...)safely updates only the query component.if request is None: raise TypeError("request cannot be null")matching other middleware.finallyover thesuper().sendcall instead of ending prematurely before the request is sent.Changes
decode_uri_encoded_stringto split query parameters and decode exclusively parameter names (supporting both uppercase and lowercase hex), leaving parameter values untouched.request.url.copy_with(query=...).super().send()intry ... finally: span.end()and addedrequest is Noneguard check.test_parameters_name_decoding_handler.py.