{"record":{"id":"ebd057e43a7a10ea","repo":"apache/hadoop","slug":"unable-to-get-log-information-for-task-oldtaskat","errorCode":null,"errorMessage":"Unable to get log information for task: {oldTaskAttemptID}","messagePattern":"Unable to get log information for task: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientServiceDelegate.java","lineNumber":512,"sourceCode":"        recordFactory.newRecordInstance(GetJobReportRequest.class);\n    request.setJobId(jobId);\n\n    JobReport report =\n        ((GetJobReportResponse) invoke(\"getJobReport\",\n            GetJobReportRequest.class, request)).getJobReport();\n    if (EnumSet.of(JobState.SUCCEEDED, JobState.FAILED, JobState.KILLED,\n        JobState.ERROR).contains(report.getJobState())) {\n      if (oldTaskAttemptID != null) {\n        GetTaskAttemptReportRequest taRequest =\n            recordFactory.newRecordInstance(GetTaskAttemptReportRequest.class);\n        taRequest.setTaskAttemptId(TypeConverter.toYarn(oldTaskAttemptID));\n        TaskAttemptReport taReport =\n            ((GetTaskAttemptReportResponse) invoke(\"getTaskAttemptReport\",\n                GetTaskAttemptReportRequest.class, taRequest))\n                .getTaskAttemptReport();\n        if (taReport.getContainerId() == null\n            || taReport.getNodeManagerHost() == null) {\n          throw new IOException(\"Unable to get log information for task: \"\n              + oldTaskAttemptID);\n        }\n        return new LogParams(\n            taReport.getContainerId().toString(),\n            taReport.getContainerId().getApplicationAttemptId()\n                .getApplicationId().toString(),\n            NodeId.newInstance(taReport.getNodeManagerHost(),\n                taReport.getNodeManagerPort()).toString(), report.getUser());\n      } else {\n        if (report.getAMInfos() == null || report.getAMInfos().size() == 0) {\n          throw new IOException(\"Unable to get log information for job: \"\n              + oldJobID);\n        }\n        AMInfo amInfo = report.getAMInfos().get(report.getAMInfos().size() - 1);\n        return new LogParams(\n            amInfo.getContainerId().toString(),\n            amInfo.getAppAttemptId().getApplicationId().toString(),\n            NodeId.newInstance(amInfo.getNodeManagerHost(),","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-jobclient/src/main/java/org/apache/hadoop/mapred/ClientServiceDelegate.java#L494-L530","documentation":"Thrown by ClientServiceDelegate.getLogFilePath when the job is in a terminal state (SUCCEEDED/FAILED/KILLED/ERROR) and a task attempt id was given, but the TaskAttemptReport obtained from the AM/history proxy has a null containerId or null nodeManagerHost. Without those fields the client cannot compute the NodeManager log address, so it raises IOException instead of returning bogus LogParams.","triggerScenarios":"Calling getJobLogFileParams/Cluster.getLogFileParams (e.g. via JobClient) for a finished job with a specific oldTaskAttemptID whose attempt never launched a container (was speculatively scheduled then pre-empted, or UNASSIGNED), or whose report from the history server lacks NM location fields.","commonSituations":"Fetching log parameters for an attempt that failed before container assignment; History server data for the attempt is partial (JHS restarted mid-job, recovery incomplete); Passing an attempt id that belongs to a different run of the job","solutions":["Use `yarn logs -applicationId <appId>` (aggregated logs) instead of per-attempt LogParams for finished jobs","Verify the attempt actually ran: check the attempt report via JHS REST .../tasks/{taskid}/attempts — attempts with no container cannot yield log paths","Retry once JHS has fully loaded the job's history (finish + cache refresh)"],"exampleFix":"# before\nLogParams lp = cluster.getLogFileParams(oldTaskAttemptID); // IOException\n\n# after\n# use the YARN CLI aggregated-log path for finished apps\nyarn logs -applicationId application_1400000000000_0001 -logFiles syslog\n# or confirm the attempt has a container first via JHS REST attempts listing","handlingStrategy":"try-catch","validationCode":"TaskAttemptReport ta = jhsRestGetAttempt(jid, tid);\nif (ta == null || ta.getContainerId() == null || ta.getNodeManagerHost() == null)\n  return Optional.empty(); // no container -> no log params possible","typeGuard":null,"tryCatchPattern":"try {\n  LogParams lp = cluster.getLogFileParams(attemptId);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Unable to get log information for task\"))\n    return fallbackToYarnLogs(appId); // `yarn logs -applicationId`\n  throw e;\n}","preventionTips":["Prefer `yarn logs -applicationId <id>` for finished jobs — it does not depend on per-attempt NM fields","Check the attempt's state via JHS REST before asking for log params; UNASSIGNED attempts have no container","Treat missing containerId/NM-host as 'attempt never launched' rather than retrying"],"tags":["hadoop","mapreduce","yarn","logs","task-attempt","null-field"],"backgroundTag":"aggregated-logs-unavailable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}