{"record":{"id":"4283ed072b0b2315","repo":"apache/hadoop","slug":"missing-attempt-state","errorCode":null,"errorMessage":"missing attempt-state.","messagePattern":"missing attempt-state\\.","errorType":"http","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AppController.java","lineNumber":292,"sourceCode":"   * Render the attempts page\n   */\n  public void attempts() {\n    try {\n      requireJob();\n    }\n    catch (Exception e) {\n      renderText(e.getMessage());\n      return;\n    }\n    if (app.getJob() != null) {\n      try {\n        String taskType = $(TASK_TYPE);\n        if (taskType.isEmpty()) {\n          throw new RuntimeException(\"missing task-type.\");\n        }\n        String attemptState = $(ATTEMPT_STATE);\n        if (attemptState.isEmpty()) {\n          throw new RuntimeException(\"missing attempt-state.\");\n        }\n        setTitle(join(attemptState, \" \",\n            MRApps.taskType(taskType).toString(), \" attempts in \", $(JOB_ID)));\n\n        render(attemptsPage());\n      } catch (Exception e) {\n        LOG.error(\"Failed to render attempts page with task type : \"\n            + $(TASK_TYPE) + \" for job id : \" + $(JOB_ID), e);\n        badRequest(e.getMessage());\n      }\n    }\n  }\n\n  /**\n   * @return the page that will be used to render the /conf page\n   */\n  protected Class<? extends View> confPage() {\n    return JobConfPage.class;","sourceCodeStart":274,"sourceCodeEnd":310,"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/AppController.java#L274-L310","documentation":"Second guard on the AM UI attempts page: after task.type passes, an empty 'attempt.state' parameter throws RuntimeException(\"missing attempt-state.\"), rendered as 400 by badRequest(). The attempt-state value must match a TaskAttemptStateUI enum name (running, succeeded, failed, killed, ...).","triggerScenarios":"Opening /attempts?job.id=...&task.type=m with no attempt.state parameter, or with an empty value (?attempt.state=).","commonSituations":"URL truncated when shared or bookmarked; scripts that know the task type but not the state; a later MRApps.taskType(taskType) failure for a bad symbol shows a different message ('Unknown task symbol').","solutions":["Add attempt.state with a TaskAttemptStateUI value, e.g. running, succeeded, failed, killed","Follow links from the job tasks table, which contain the full query string","Validate both parameters in one place when you generate such URLs"],"exampleFix":"// before\nhttp://am-host:8099/attempts?job.id=job_1401318629735_0001&task.type=m\n// 400 missing attempt-state.\n\n// after\nhttp://am-host:8099/attempts?job.id=job_1401318629735_0001&task.type=m&attempt.state=running","handlingStrategy":"validation","validationCode":"private static final Set<String> ATTEMPT_STATES = Set.of(\n    \"running\", \"succeeded\", \"failed\", \"killed\", \"started\", \"commit_pending\", \"new\");\n\nif (attemptState == null || attemptState.isEmpty()\n    || !ATTEMPT_STATES.contains(attemptState.toLowerCase())) {\n  throw new IllegalArgumentException(\"attempt.state required and must be a TaskAttemptStateUI value\");\n}","typeGuard":"static boolean isValidAttemptStateParam(String s) {\n  try {\n    org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptStateUI.valueOf(\n        s == null ? \"\" : s.toUpperCase());\n    return true;\n  } catch (IllegalArgumentException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Treat task.type and attempt.state as one unit - validate both before opening the page","Use enum names of TaskAttemptStateUI for the state value","Follow links generated by the UI rather than constructing query strings by hand"],"tags":["mapreduce","web-ui","http-400","applicationmaster","query-parameter"],"backgroundTag":"missing-required-query-parameter","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}