This is an automated email from the ASF dual-hosted git repository.

eladkal pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 14b631294d Fix: Only quote the keys of the query_parameters in 
MSGraphOperator (#39207)
14b631294d is described below

commit 14b631294d07e3323905bde4e9bf257be5d7ba5e
Author: David Blain <[email protected]>
AuthorDate: Wed Apr 24 15:23:21 2024 +0200

    Fix: Only quote the keys of the query_parameters in MSGraphOperator (#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]>
---
 airflow/providers/microsoft/azure/triggers/msgraph.py    |  2 +-
 tests/providers/microsoft/azure/triggers/test_msgraph.py | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/airflow/providers/microsoft/azure/triggers/msgraph.py 
b/airflow/providers/microsoft/azure/triggers/msgraph.py
index c0e5ee85a0..814a91f7c1 100644
--- a/airflow/providers/microsoft/azure/triggers/msgraph.py
+++ b/airflow/providers/microsoft/azure/triggers/msgraph.py
@@ -270,7 +270,7 @@ class MSGraphTrigger(BaseTrigger):
 
     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:
diff --git a/tests/providers/microsoft/azure/triggers/test_msgraph.py 
b/tests/providers/microsoft/azure/triggers/test_msgraph.py
index 900d0875cd..a4e2c7f0fd 100644
--- a/tests/providers/microsoft/azure/triggers/test_msgraph.py
+++ b/tests/providers/microsoft/azure/triggers/test_msgraph.py
@@ -132,6 +132,17 @@ class TestMSGraphTrigger(Base):
         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):

Reply via email to