apache/hadoop · error · RuntimeException

missing attempt-state.

Error message

missing attempt-state.

What it means

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, ...).

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-app/src/main/java/org/apache/hadoop/mapreduce/v2/app/webapp/AppController.java:292

   * Render the attempts page
   */
  public void attempts() {
    try {
      requireJob();
    }
    catch (Exception e) {
      renderText(e.getMessage());
      return;
    }
    if (app.getJob() != null) {
      try {
        String taskType = $(TASK_TYPE);
        if (taskType.isEmpty()) {
          throw new RuntimeException("missing task-type.");
        }
        String attemptState = $(ATTEMPT_STATE);
        if (attemptState.isEmpty()) {
          throw new RuntimeException("missing attempt-state.");
        }
        setTitle(join(attemptState, " ",
            MRApps.taskType(taskType).toString(), " attempts in ", $(JOB_ID)));

        render(attemptsPage());
      } catch (Exception e) {
        LOG.error("Failed to render attempts page with task type : "
            + $(TASK_TYPE) + " for job id : " + $(JOB_ID), e);
        badRequest(e.getMessage());
      }
    }
  }

  /**
   * @return the page that will be used to render the /conf page
   */
  protected Class<? extends View> confPage() {
    return JobConfPage.class;

View on GitHub (pinned to 2add963021)

Solutions

  1. Add attempt.state with a TaskAttemptStateUI value, e.g. running, succeeded, failed, killed
  2. Follow links from the job tasks table, which contain the full query string
  3. Validate both parameters in one place when you generate such URLs

Example fix

// before
http://am-host:8099/attempts?job.id=job_1401318629735_0001&task.type=m
// 400 missing attempt-state.

// after
http://am-host:8099/attempts?job.id=job_1401318629735_0001&task.type=m&attempt.state=running
Defensive patterns

Strategy: validation

Validate before calling

private static final Set<String> ATTEMPT_STATES = Set.of(
    "running", "succeeded", "failed", "killed", "started", "commit_pending", "new");

if (attemptState == null || attemptState.isEmpty()
    || !ATTEMPT_STATES.contains(attemptState.toLowerCase())) {
  throw new IllegalArgumentException("attempt.state required and must be a TaskAttemptStateUI value");
}

Type guard

static boolean isValidAttemptStateParam(String s) {
  try {
    org.apache.hadoop.mapreduce.v2.app.webapp.dao.TaskAttemptStateUI.valueOf(
        s == null ? "" : s.toUpperCase());
    return true;
  } catch (IllegalArgumentException e) { return false; }
}

Prevention

When it happens

Trigger: Opening /attempts?job.id=...&task.type=m with no attempt.state parameter, or with an empty value (?attempt.state=).

Common situations: 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').

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/4283ed072b0b2315. Report an issue: GitHub.