{"record":{"id":"26082998cd20cbd0","repo":"apache/hadoop","slug":"error-getting-info-on-task-attempt-id","errorCode":null,"errorMessage":"Error getting info on task attempt id {}","messagePattern":"Error getting info on task attempt id (.+?)","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AMWebServices.java","lineNumber":220,"sourceCode":"      // TODO: after MAPREDUCE-2793 YarnRuntimeException is probably not expected here\n      // anymore but keeping it for now just in case other stuff starts failing.\n      // Also, the webservice should ideally return BadRequest (HTTP:400) when\n      // the id is malformed instead of NotFound (HTTP:404). The webserver on\n      // top of which AMWebServices is built seems to automatically do that for\n      // unhandled exceptions\n      throw new NotFoundException(e.getMessage());\n    } catch (NumberFormatException ne) {\n      throw new NotFoundException(ne.getMessage());\n    } catch (IllegalArgumentException e) {\n      throw new NotFoundException(e.getMessage());\n    }\n    if (attemptId == null) {\n      throw new NotFoundException(\"task attempt id \" + attId\n          + \" not found or invalid\");\n    }\n    ta = task.getAttempt(attemptId);\n    if (ta == null) {\n      throw new NotFoundException(\"Error getting info on task attempt id \"\n          + attId);\n    }\n    return ta;\n  }\n\n\n  /**\n   * check for job access.\n   *\n   * @param job\n   *          the job that is being accessed\n   */\n  void checkAccess(Job job, HttpServletRequest request) {\n    if (!hasAccess(job, request)) {\n      throw new WebApplicationException(Status.UNAUTHORIZED);\n    }\n  }\n","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AMWebServices.java#L202-L238","documentation":"The attempt id parsed into a TaskAttemptId, but task.getAttempt(attemptId) returned null: the resolved task does not contain that attempt. The AM REST API returns HTTP 404 with 'Error getting info on task attempt id <attId>'.","triggerScenarios":"GET .../tasks/{taskid}/attempts/{attemptid} (also /counters and PUT /state) where the attempt id's task portion differs from {taskid} - e.g. attempt_..._m_000005_0 sent under tasks/task_..._m_000006 - or the attempt number does not exist (asking for _1 when only _0 ran).","commonSituations":"Ids of retries or speculative attempts after a task re-runs; off-by-one in generated attempt numbers; copy-paste across tasks; querying after task restart moved the live attempt to a higher number.","solutions":["List attempts with GET .../tasks/{taskid}/attempts and use an id from that response","Confirm the attempt id without its last '_<n>' segment equals the {taskid} in the URL","For finished jobs use the Job History Server REST API instead of the AM"],"exampleFix":"// before: attempt of task m_000006 sent under task m_000005\nGET .../tasks/task_1_0001_m_000005/attempts/attempt_1_0001_m_000006_0\n// 404 { \"Error getting info on task attempt id ...\" }\n\n// after: attempt belongs to the addressed task\nGET .../tasks/task_1_0001_m_000005/attempts/attempt_1_0001_m_000005_0","handlingStrategy":"validation","validationCode":"// The attempt id must be an extension of the task id it is queried under\nString taskPrefix = tid; // e.g. task_1_0001_m_000005\nif (!attId.startsWith(taskPrefix + \"_\")) {\n  // attempt belongs to a different task; fix the URL or fetch the attempt list\n}","typeGuard":"static boolean attemptBelongsToTask(String attId, String tid) {\n  return attId != null && tid != null && attId.startsWith(tid + \"_\");\n}","tryCatchPattern":"try {\n  return getAttempt(jid, tid, attId);\n} catch (javax.ws.rs.NotFoundException e) {\n  // valid id but not an attempt of this task: list attempts and pick the latest\n  attempts = listAttempts(jid, tid);\n}","preventionTips":["Fetch the attempt list per task before addressing an attempt","Re-fetch after task retries or speculation - the live attempt number changes","Verify the attempt id minus its last segment equals the task id"],"tags":["mapreduce","rest","http-404","applicationmaster","task-attempt-id"],"backgroundTag":"rest-resource-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}