From e772838968692364da8921b6c492fa785c08e8ae Mon Sep 17 00:00:00 2001 From: JP Bruins Slot Date: Wed, 15 Jan 2025 16:58:27 +0100 Subject: [PATCH] Fix task runner --- boefjes/boefjes/clients/scheduler_client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/boefjes/boefjes/clients/scheduler_client.py b/boefjes/boefjes/clients/scheduler_client.py index 015c2539a89..edb5c02ac5c 100644 --- a/boefjes/boefjes/clients/scheduler_client.py +++ b/boefjes/boefjes/clients/scheduler_client.py @@ -83,7 +83,10 @@ def pop_item(self, scheduler_id: str) -> Task | None: self._verify_response(response) page = TypeAdapter(PaginatedTasksResponse | None).validate_json(response.content) - return TypeAdapter(Task | None).validate_json(page.results[0]) if page else None + if page.count == 0: + return None + + return page.results[0] def pop_items(self, scheduler_id: str, filters: dict[str, Any]) -> PaginatedTasksResponse | None: response = self._session.post(f"/schedulers/{scheduler_id}/pop", json=filters)