apache/hadoop · warning · NotFoundException
taskid {tid} not found or invalid
Error message
taskid {tid} not found or invalid What it means
Returned as HTTP 404 by the JobHistoryServer REST task endpoints (e.g. GET /ws/v1/history/mapreduce/jobs/{jobid}/tasks/{taskid}/counters) when MRApps.toTaskID(tid) yields null, i.e. the {taskid} path segment cannot be converted into a TaskId object. This is the guard for unparseable or invalid task identifiers before the job's task map is consulted. Note: because TaskID.forName uses a strict regex (task_<jobTimestamp>_<jobId>_[m|r]_<taskNum>), many malformed ids also surface as 400/500 from the parser; this 404 covers the null-return path and ids that parse structurally but do not belong to the job.
Source
Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsWebServices.java:389
Task task = AMWebServices.getTaskFromTaskIdString(tid, job);
return new TaskInfo(task);
}
@GET
@Path("/mapreduce/jobs/{jobid}/tasks/{taskid}/counters")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public JobTaskCounterInfo getSingleTaskCounters(
@Context HttpServletRequest hsr, @PathParam("jobid") String jid,
@PathParam("taskid") String tid) {
init();
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);
checkAccess(job, hsr);
TaskId taskID = MRApps.toTaskID(tid);
if (taskID == null) {
throw new NotFoundException("taskid " + tid + " not found or invalid");
}
Task task = job.getTask(taskID);
if (task == null) {
throw new NotFoundException("task not found with id " + tid);
}
return new JobTaskCounterInfo(task);
}
@GET
@Path("/mapreduce/jobs/{jobid}/tasks/{taskid}/attempts")
@Produces({ MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
MediaType.APPLICATION_XML + "; " + JettyUtils.UTF_8 })
public TaskAttemptsInfo getJobTaskAttempts(@Context HttpServletRequest hsr,
@PathParam("jobid") String jid, @PathParam("taskid") String tid) {
init();
TaskAttemptsInfo attempts = new TaskAttemptsInfo();
Job job = AMWebServices.getJobFromJobIdString(jid, ctx);View on GitHub (pinned to 2add963021)
Solutions
- Use a task id of the exact form task_<timestamp>_<seq>_[m|r]_<n> taken from the job's task listing
- List tasks first (GET .../tasks) and copy the id field from the response
- Do not substitute attempt ids; attempts live under .../tasks/{taskid}/attempts
Example fix
# before curl "http://jhs:19888/ws/v1/history/mapreduce/jobs/$JID/tasks/attempt_1400000000000_0001_m_000000_0/counters" # after curl "http://jhs:19888/ws/v1/history/mapreduce/jobs/$JID/tasks/task_1400000000000_0001_m_000000/counters"
Defensive patterns
Strategy: validation
Validate before calling
private static final Pattern TASK_ID =
Pattern.compile("task_\\d+_\\d+_[mr]_\\d+");
boolean isValidTaskId(String tid) {
return tid != null && TASK_ID.matcher(tid).matches()
&& tid.startsWith("task_" + jobIdSubstring(jid)); // embedded job must match
} Type guard
boolean isRequestableTaskId(String tid) {
return tid != null && TASK_ID.matcher(tid).matches();
} Try / catch
try { counters = jhsClient.getTaskCounters(jid, tid); }
catch (NotFoundException e) { /* unknown or invalid task id for this job */ } Prevention
- Always source task ids from the .../tasks listing response, never construct them by string surgery
- Pass task_ ids to task endpoints and attempt_ ids to attempt endpoints — never interchange
- A well-formed id from another job parses fine but 404s at the job lookup — keep ids paired with their job
When it happens
Trigger: GET /ws/v1/history/mapreduce/jobs/job_1400000000000_0001/tasks/task_9999999999999_0001_m_0/counters — a task id whose embedded job portion or format is wrong (e.g. attempt_... passed instead of task_..., missing trailing task number).
Common situations: Passing an attempt id (attempt_...) where a task id (task_...) is required; Cutting the id short or including the '_m_'/'_r_' literal from documentation examples; Mixing ids from a different job or cluster (valid shape, unknown to this job)
Related errors
- task not found with id {tid}
- unable to load configuration for job: {jid}
- taskid {} not found or invalid
- task not found with id {}
- startedTimeEnd must be greater than 0
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/867306b533244577.
Report an issue: GitHub.