Repository navigation
fix(abstractions): preserve multi-valued query parameters in ApiKeyAuthenticationProvider - #913
Closed
Hardik K (hardikkaurani) wants to merge 2 commits into
Conversation
…thenticationProvider Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…eters in ApiKeyAuthenticationProvider Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Contributor
Author
|
This PR addresses an issue where multi-valued query parameters were lost when authenticating requests with
All checks pass locally in |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
ApiKeyAuthenticationProviderauthenticates a request usingKeyLocation.QueryParameter, it parsed the query component ofrequest.urlviadict(parse_qsl(url_parts[4], keep_blank_values=True)).Converting
parse_qsldirectly to a Pythondictcauses all repeated / multi-valued query parameters (such as?id=1&id=2or?expand=orders&expand=items) to be collapsed into a single key-value pair, silently discarding earlier values.This PR preserves all existing query parameters as a list of key-value pairs (
parse_qsl), filters out any existing parameter matchingself.parameter_name(to avoid duplicate key insertions if updating or re-authenticating), appends(self.parameter_name, self.api_key), and re-encodes the query string viaurlencode.Changes
fix): UpdateApiKeyAuthenticationProvider.authenticate_requestto preserve multi-valued query parameter pairs instead of collapsing them into a dictionary.test): Add regression tests verifying that:?id=1&id=2&select=name) are preserved alongside the newly added API key.Verification
Ran test suites and linters locally against
packages/abstractions:pytest: 268/268 passed (100% pass rate)mypy kiota_abstractions: Success (no issues found in 48 source files)pylint kiota_abstractions --disable=W --rcfile=.pylintrc: 10.00/10yapf -dr kiota_abstractions: cleanisort --check kiota_abstractions/authentication/api_key_authentication_provider.py: cleanpytest packages/http/httpx: 227/227 passed