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

dabla 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 cbedeaba147 Keep MSGraph path parameters across paginated pages 
(#71866)
cbedeaba147 is described below

commit cbedeaba147bd8734ff9441de856b8a63a56629e
Author: PoAn Yang <[email protected]>
AuthorDate: Fri Aug 21 21:17:53 2026 +0900

    Keep MSGraph path parameters across paginated pages (#71866)
    
    Signed-off-by: PoAn Yang <[email protected]>
---
 .../providers/microsoft/azure/operators/msgraph.py |  1 +
 .../unit/microsoft/azure/operators/test_msgraph.py | 43 ++++++++++++++++++++++
 .../unit/microsoft/azure/resources/messages.json   |  1 +
 .../microsoft/azure/resources/next_messages.json   |  1 +
 4 files changed, 46 insertions(+)

diff --git 
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py
 
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py
index 7cd68b64706..40782fdba5d 100644
--- 
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py
+++ 
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/msgraph.py
@@ -341,6 +341,7 @@ class MSGraphAsyncOperator(BaseOperator):
                     trigger=MSGraphTrigger(
                         url=url,
                         method=self.method,
+                        path_parameters=self.path_parameters,
                         query_parameters=query_parameters,
                         headers=self.headers,
                         data=self.data,
diff --git 
a/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
 
b/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
index b722bc4a617..b18842087e4 100644
--- 
a/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
+++ 
b/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_msgraph.py
@@ -342,6 +342,49 @@ class TestMSGraphAsyncOperator:
         assert trigger.data == data
         assert trigger.scopes == scopes
 
+    def test_trigger_next_link_forwards_the_path_parameters(self):
+        path_parameters = {"user_id": "48d31887-5fad-4d73-a9f5-3c356e68a038", 
"mailFolder_id": "inbox"}
+        operator = MSGraphAsyncOperator(
+            task_id="messages",
+            conn_id="msgraph_api",
+            url="users/{user_id}/mailFolders/{mailFolder_id}/messages",
+            path_parameters=path_parameters,
+            query_parameters={"$top": 12, "$count": True},
+        )
+        context = mock_context(task=operator)
+        messages = load_json_from_resources(dirname(__file__), "..", 
"resources", "messages.json")
+
+        with mock.patch.object(operator, "defer") as mock_defer:
+            operator.trigger_next_link(messages, 
method_name="execute_complete", context=context)
+
+        trigger = mock_defer.call_args.kwargs["trigger"]
+        assert trigger.url == 
"users/{user_id}/mailFolders/{mailFolder_id}/messages"
+        assert trigger.path_parameters == path_parameters
+
+    def test_skip_pagination_expands_the_url_template_on_every_page(self):
+        messages = load_json_from_resources(dirname(__file__), "..", 
"resources", "messages.json")
+        next_messages = load_json_from_resources(dirname(__file__), "..", 
"resources", "next_messages.json")
+        response = mock_json_response(200, messages, next_messages)
+
+        with patch_hook_and_request_adapter(response) as (*_, 
mock_get_http_response):
+            operator = MSGraphAsyncOperator(
+                task_id="messages",
+                conn_id="msgraph_api",
+                url="users/{user_id}/mailFolders/{mailFolder_id}/messages",
+                path_parameters={"user_id": 
"48d31887-5fad-4d73-a9f5-3c356e68a038", "mailFolder_id": "inbox"},
+                query_parameters={"$top": 12, "$count": True},
+                result_processor=lambda result, **context: result.get("value"),
+            )
+
+            execute_operator(operator)
+
+        urls = [call.args[0].url for call in 
mock_get_http_response.call_args_list]
+
+        assert urls == [
+            
"users/48d31887-5fad-4d73-a9f5-3c356e68a038/mailFolders/inbox/messages?%24top=12&%24count=true",
+            
"users/48d31887-5fad-4d73-a9f5-3c356e68a038/mailFolders/inbox/messages?%24top=12&%24count=true&%24skip=12",
+        ]
+
     def test_pagination_issues_every_page_with_the_configured_request(self):
         users = load_json_from_resources(dirname(__file__), "..", "resources", 
"users.json")
         next_users = load_json_from_resources(dirname(__file__), "..", 
"resources", "next_users.json")
diff --git 
a/providers/microsoft/azure/tests/unit/microsoft/azure/resources/messages.json 
b/providers/microsoft/azure/tests/unit/microsoft/azure/resources/messages.json
new file mode 100644
index 00000000000..e8994c021c9
--- /dev/null
+++ 
b/providers/microsoft/azure/tests/unit/microsoft/azure/resources/messages.json
@@ -0,0 +1 @@
+{"@odata.context": 
"https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/mailFolders('inbox')/messages",
 "@odata.count": 18, "@odata.nextLink": 
"https://graph.microsoft.com/v1.0/users('48d31887-5fad-4d73-a9f5-3c356e68a038')/mailFolders('inbox')/messages?%24top=12&%24count=true&%24skip=12",
 "value": [{"@odata.etag": "W/\"CQAAABYAAADHcgC8Hl9tRZ/hc1wEUs1TAAAwR4Hg\"", 
"id": "AAMkAGUAAAwTW09AAA=", "subject": "Weekly status report", 
"receivedDateTime": "2026 [...]
diff --git 
a/providers/microsoft/azure/tests/unit/microsoft/azure/resources/next_messages.json
 
b/providers/microsoft/azure/tests/unit/microsoft/azure/resources/next_messages.json
new file mode 100644
index 00000000000..81470210d56
--- /dev/null
+++ 
b/providers/microsoft/azure/tests/unit/microsoft/azure/resources/next_messages.json
@@ -0,0 +1 @@
+{"@odata.context": 
"https://graph.microsoft.com/v1.0/$metadata#users('48d31887-5fad-4d73-a9f5-3c356e68a038')/mailFolders('inbox')/messages",
 "@odata.count": 18, "value": [{"@odata.etag": 
"W/\"CQAAABYAAADHcgC8Hl9tRZ/hc1wEUs1TAAAwSp4B\"", "id": "AAMkAGUAAAwTXCMAAA=", 
"subject": "Re: Deployment window moved", "receivedDateTime": 
"2026-08-17T09:18:47Z", "isRead": true}, {"@odata.etag": 
"W/\"CQAAABYAAADHcgC8Hl9tRZ/hc1wEUs1TAAAwStQm\"", "id": "AAMkAGUAAAwTXDNAAA=", 
"subject": "Offsite logistic [...]

Reply via email to