henry3260 commented on code in PR #68616:
URL: https://github.com/apache/airflow/pull/68616#discussion_r3537539863


##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -688,6 +693,22 @@ def list(
             params["hostname"] = hostname
         if is_alive is not None:
             params["is_alive"] = is_alive
+        if dag_id:
+            params["dag_id"] = dag_id
+        if state:
+            params["job_state"] = state
+        if order_by:
+            params["order_by"] = order_by
+        elif limit is not None:
+            params["order_by"] = "-start_date"
+        if limit is not None:
+            params["limit"] = limit
+        if offset is not None:
+            params["offset"] = offset
+
+        if limit is not None or offset is not None:
+            self.response = self.client.get("jobs", params=params)
+            return 
JobCollectionResponse.model_validate_json(self.response.content)

Review Comment:
   > I have tried with this use case :
   > 
   > Direct response :
   > 
   > ```
   > $ airflowctl jobs list --limit=2 --offset=3
   > Please enter password for encrypted keyring: 
   > [{"id": "15", "dag_id": null, "state": "running", "job_type": 
"TriggererJob", "start_date": "2026-07-06T12:56:50.079485Z", "end_date": null, 
"latest_heartbeat": "2026-07-06T13:44:44.463361Z", "executor_class": null, 
"hostname": "ceb251a61baf", "unixname": "root", "dag_display_name": null}, 
{"id": "14", "dag_id": null, "state": "failed", "job_type": "SchedulerJob", 
"start_date": "2026-07-06T12:56:49.536027Z", "end_date": null, 
"latest_heartbeat": "2026-07-06T13:44:46.614659Z", "executor_class": null, 
"hostname": "ceb251a61baf", "unixname": "root", "dag_display_name": null}]
   > ```
   > 
   > this with execute_list() :
   > 
   > ```
   > [Breeze:3.10.20] root@a2c0e153df89:/opt/airflow$ airflowctl jobs list 
--limit=2 --offset=3
   > Please enter password for encrypted keyring: 
   > limit 50 offset 0
   > execute_list params {'order_by': '-start_date', 'limit': 2, 'offset': 3}
   > total_entries 18
   > [{"id": "15", "dag_id": null, "state": "running", "job_type": 
"TriggererJob", "start_date": "2026-07-06T12:56:50.079485Z", "end_date": null, 
"latest_heartbeat": "2026-07-06T13:44:44.463361Z", "executor_class": null, 
"hostname": "ceb251a61baf", "unixname": "root", "dag_display_name": null}, 
{"id": "14", "dag_id": null, "state": "failed", "job_type": "SchedulerJob", 
"start_date": "2026-07-06T12:56:49.536027Z", "end_date": null, 
"latest_heartbeat": "2026-07-06T13:44:46.614659Z", "executor_class": null, 
"hostname": "ceb251a61baf", "unixname": "root", "dag_display_name": null}]
   > ```
   > 
   > would love to hear your thoughts Henry !
   
   Thanks for checking this. I think this case happens to return the same 
result because `total_entries` is 18, which is smaller than `execute_list()`'s 
internal default `limit=50`.
   So we only meet this issue when `total_entries` > default `limit=50`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to