{"record":{"id":"7fce7ec75a540fee","repo":"prestodb/presto","slug":"taskinfo-not-found-for-task-id","errorCode":null,"errorMessage":"TaskInfo not found for task id ","messagePattern":"TaskInfo not found for task id ","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"warning","filePath":"presto-main/src/main/java/com/facebook/presto/server/TaskInfoResource.java","lineNumber":122,"sourceCode":"    private TaskInfo getTaskInfo(TaskId taskId)\n    {\n        QueryId queryId = taskId.getQueryId();\n        try {\n            Optional<StageInfo> stageInfo = queryManager.getFullQueryInfo(queryId).getOutputStage();\n\n            if (stageInfo.isPresent()) {\n                Optional<StageInfo> stage = stageInfo.get().getStageWithStageId(taskId.getStageExecutionId().getStageId());\n                if (stage.isPresent()) {\n                    Optional<TaskInfo> taskInfo = stage.get().getLatestAttemptExecutionInfo().getTasks().stream()\n                            .filter(info -> info.getTaskId().equals(taskId))\n                            .findFirst();\n\n                    if (taskInfo.isPresent()) {\n                        return taskInfo.get();\n                    }\n                }\n            }\n            throw new NotFoundException(\"TaskInfo not found for task id \" + taskId.toString());\n        }\n        catch (Exception e) {\n            throw new NotFoundException(e);\n        }\n    }\n\n    private boolean requestNeedsToBeProxied(TaskId taskId, boolean includeLocalQueryOnly)\n    {\n        return !includeLocalQueryOnly\n                && resourceManagerEnabled\n                && !dispatchManager.isQueryPresent(taskId.getQueryId());\n    }\n\n    private URI createTaskInfoUri(UriInfo uriInfo, InternalNode resourceManagerNode)\n            throws UnknownHostException\n    {\n        return UriBuilder.fromUri(uriInfo.getRequestUri())\n                .queryParam(INCLUDE_LOCAL_QUERY_ONLY, true)","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main/src/main/java/com/facebook/presto/server/TaskInfoResource.java#L104-L140","documentation":"getTaskInfo cannot locate TaskInfo for the requested task id on this node and throws a JAX-RS NotFoundException (HTTP 404). Tasks are short-lived and their info is retained only briefly, so lookups can legitimately miss.","triggerScenarios":"GET /v1/task/{taskId} (or the UI task info endpoint) for a taskId that never ran on this node, already finished and was evicted from SqlTaskManager, or the query was cancelled.","commonSituations":"Stale task references in client code or UI bookmarks after query completion, load balancer routing to a node that never owned the task, retries after a task was already cleaned up, split failures surfacing as missing tasks.","solutions":["Retry against the coordinator, which routes task info requests to the correct node","Refresh query/task state from the coordinator's query info instead of caching task IDs","Handle 404 as 'task completed or never existed' in client logic rather than a hard failure","Shorten the gap between getting the taskId and fetching its info in custom tooling"],"exampleFix":"// before\nTaskInfo info = taskClient.getTaskInfo(taskId); // throws if gone\n// after\nOptional<TaskInfo> info = taskClient.getTaskInfoIfPresent(taskId);\nif (!info.isPresent()) { refreshFromQueryInfo(queryId); }","handlingStrategy":"try-catch","validationCode":"// Check task/query still active via coordinator first: GET /v1/query/{queryId} — skip task fetch if state is FINISHED/FAILED","typeGuard":"boolean isFetchableTaskId(TaskId taskId) { return taskId != null && !taskId.toString().isEmpty(); }","tryCatchPattern":"try { return taskClient.getTaskInfo(taskId); } catch (NotFoundException e) { LOG.info(\"Task %s already completed or evicted\", taskId); return Optional.empty(); }","preventionTips":["Treat 404 on task info as a normal terminal outcome in distributed queries","Route task info requests through the coordinator, not directly at arbitrary nodes","Avoid long-lived caching of TaskId references; refresh from query info"],"tags":["http-404","notfound","distributed-state"],"backgroundTag":"resource-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}