Skip to content

Commit d166904

Browse files
jcristauahal
authored andcommitted
fix: restore pagination handling for batched APIs
Regression from #741
1 parent 2b5232c commit d166904

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

src/taskgraph/util/taskcluster.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,20 @@ 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})
190-
191-
if not response or "tasks" not in response:
192-
return {}
189+
task_ids = {}
190+
191+
def pagination_handler(response):
192+
task_ids.update(
193+
{
194+
t["namespace"]: t["taskId"]
195+
for t in response["tasks"]
196+
if "namespace" in t and "taskId" in t
197+
}
198+
)
193199

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-
}
200+
index.findTasksAtIndex(
201+
payload={"indexes": index_paths}, paginationHandler=pagination_handler
202+
)
198203

199204
return task_ids
200205

@@ -296,17 +301,19 @@ def status_task_batched(task_ids):
296301
return {}
297302

298303
queue = get_taskcluster_client("queue")
299-
response = queue.statuses({"taskIds": task_ids})
304+
statuses = {}
305+
306+
def pagination_handler(response):
307+
statuses.update(
308+
{
309+
t["taskId"]: t["status"]
310+
for t in response.get("statuses", [])
311+
if "namespace" in t and "taskId" in t
312+
}
313+
)
300314

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

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-
}
310317
return statuses
311318

312319

0 commit comments

Comments
 (0)