Skip to content

Commit

Permalink
Fix: Only quote the keys of the query_parameters in MSGraphOperator (a…
Browse files Browse the repository at this point in the history
…pache#39207)

* fix: Make sure the encoded_query_parameters function of the MSGraphTrigger only encodes the keys and not the values otherwise those will be encoded twice

* refactor: Added missing coma

---------

Co-authored-by: David Blain <[email protected]>
  • Loading branch information
dabla and davidblain-infrabel authored Apr 24, 2024
1 parent c434c6b commit 14b6312
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion airflow/providers/microsoft/azure/triggers/msgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def normalize_url(self) -> str | None:

def encoded_query_parameters(self) -> dict:
if self.query_parameters:
return {quote(key): quote(str(value)) for key, value in self.query_parameters.items()}
return {quote(key): value for key, value in self.query_parameters.items()}
return {}

def request_information(self) -> RequestInformation:
Expand Down
11 changes: 11 additions & 0 deletions tests/providers/microsoft/azure/triggers/test_msgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ def test_template_fields(self):
for template_field in MSGraphTrigger.template_fields:
getattr(trigger, template_field)

def test_encoded_query_parameters(self):
trigger = MSGraphTrigger(
url="myorg/admin/groups",
conn_id="msgraph_api",
query_parameters={"$expand": "reports,users,datasets,dataflows,dashboards", "$top": 5000},
)

actual = trigger.encoded_query_parameters()

assert actual == {"%24expand": "reports,users,datasets,dataflows,dashboards", "%24top": 5000}


class TestResponseHandler:
def test_handle_response_async(self):
Expand Down

0 comments on commit 14b6312

Please sign in to comment.