Skip to content

Commit 3e61331

Browse files
committed
fix: restore pagination handling for batched APIs
Regression from #741
1 parent d03117e commit 3e61331

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

src/taskgraph/util/taskcluster.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,11 @@ def find_task_id_batched(index_paths):
186186
https://docs.taskcluster.net/docs/reference/core/index/api#findTasksAtIndex
187187
"""
188188
index = get_taskcluster_client("index")
189-
response = index.findTasksAtIndex({"indexes": index_paths})
189+
task_ids = {}
190+
def pagination_handler(response):
191+
task_ids.update({["namespace"]: t["taskId"] for t in response["tasks"] if "namespace" in t and "taskId" in t})
190192

191-
if not response or "tasks" not in response:
192-
return {}
193-
194-
tasks = response.get("tasks", [])
195-
task_ids = {
196-
t["namespace"]: t["taskId"] for t in tasks if "namespace" in t and "taskId" in t
197-
}
193+
index.findTasksAtIndex(payload={"indexes": index_paths}, paginationHandler=pagination_handler)
198194

199195
return task_ids
200196

@@ -296,17 +292,12 @@ def status_task_batched(task_ids):
296292
return {}
297293

298294
queue = get_taskcluster_client("queue")
299-
response = queue.statuses({"taskIds": task_ids})
295+
statuses = {}
296+
def pagination_handler(response):
297+
statuses.update({t["taskId"]: t["status"] for t in response.get("statuses", []) if "namespace" in t and "taskId" in t})
300298

301-
if not response or "statuses" not in response:
302-
return {}
299+
queue.statuses(payload={"taskIds": task_ids}, paginationHandler=pagination_handler)
303300

304-
status_list = response.get("statuses", [])
305-
statuses = {
306-
t["taskId"]: t["status"]
307-
for t in status_list
308-
if "namespace" in t and "taskId" in t
309-
}
310301
return statuses
311302

312303

0 commit comments

Comments
 (0)