{"record":{"id":"34776d116c5ee547","repo":"docling-project/docling","slug":"task-task-id-was-not-found","errorCode":null,"errorMessage":"Task {task_id} was not found.","messagePattern":"Task (.+?) was not found\\.","errorType":"exception","errorClass":"TaskNotFoundError","httpStatus":404,"severity":"error","filePath":"docling/service_client/_async_client.py","lineNumber":856,"sourceCode":"                path=f\"/v1/chunk/{chunker.value}/file/async\",\n                data=self._form_encode_options(data),\n                files=files,\n            )\n\n        if response.status_code != 200:\n            self._raise_for_generic_http_error(\n                response, \"Chunk task submission failed.\"\n            )\n        return TaskStatusResponse.model_validate_json(response.text)\n\n    async def _poll_task_status(self, task_id: str, wait: float) -> TaskStatusResponse:\n        response = await self._request_with_retry(\n            method=\"GET\",\n            path=f\"/v1/status/poll/{task_id}\",\n            params={\"wait\": wait},\n        )\n        if response.status_code == 404:\n            raise TaskNotFoundError(f\"Task {task_id} was not found.\")\n        if response.status_code != 200:\n            self._raise_for_generic_http_error(\n                response, f\"Polling task {task_id} failed.\"\n            )\n        return TaskStatusResponse.model_validate_json(response.text)\n\n    async def _poll_task_status_using_client(\n        self,\n        task_id: str,\n        wait: float,\n        async_client: httpx.AsyncClient,\n    ) -> TaskStatusResponse:\n        response = await self._request_with_retry_using_client(\n            async_client=async_client,\n            method=\"GET\",\n            path=f\"/v1/status/poll/{task_id}\",\n            params={\"wait\": wait},\n        )","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/service_client/_async_client.py#L838-L874","documentation":"While polling task status via GET /v1/status/poll/{task_id}, the service returned HTTP 404, meaning no task with that identifier exists (anymore). The async client translates this into TaskNotFoundError. Common causes are an expired/completed-and-evicted task, a wrong task_id, or querying a different service instance that never held the task.","triggerScenarios":"Polling a task after the service's retention window has evicted it; using a task_id from a previous deployment or another service instance (e.g. after a container restart with in-memory task store); typo'd or truncated task_id; task record removed once terminal results were garbage-collected.","commonSituations":"Resuming a batch job after a long pause or service restart; multiple replicas behind a load balancer without shared task state; storing task ids in a queue and processing them hours later.","solutions":["Poll promptly after submitting and keep the polling session within the service's task retention window.","Ensure sticky routing or a shared task backend when running multiple service replicas.","Verify the task_id string matches the one returned at submission.","On TaskNotFoundError, treat the task as lost and resubmit the conversion rather than polling forever."],"exampleFix":"# before\nstatus = await client._poll_task_status(task_id, wait=30.0)  # 404 -> TaskNotFoundError\n\n# after\nfrom docling.service_client.exceptions import TaskNotFoundError\ntry:\n    status = await client.wait_for_task(task_id)\nexcept TaskNotFoundError:\n    job = await client.submit(...); task_id = job.task_id  # resubmit","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from docling.service_client.exceptions import TaskNotFoundError\n\ntry:\n    status = await poll(task_id)\nexcept TaskNotFoundError:\n    job = await resubmit(source)  # task evicted/lost; convert again","preventionTips":["Poll tasks soon after submission; don't resume hours later.","Persist source documents so tasks can always be resubmitted.","Use shared task storage when running multiple service replicas."],"tags":["service-client","task","polling","not-found"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}