{"record":{"id":"3ae7d1451fcec9f0","repo":"apache/hadoop","slug":"jobid-string-is-not-properly-formed","errorCode":null,"errorMessage":"JobId string : {} is not properly formed","messagePattern":"JobId string : (.+?) is not properly formed","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobID.java","lineNumber":156,"sourceCode":"  \n  /** Construct a JobId object from given string \n   * @return constructed JobId object or null if the given String is null\n   * @throws IllegalArgumentException if the given string is malformed\n   */\n  public static JobID forName(String str) throws IllegalArgumentException {\n    if(str == null)\n      return null;\n    try {\n      String[] parts = str.split(\"_\");\n      if(parts.length == 3) {\n        if(parts[0].equals(JOB)) {\n          return new org.apache.hadoop.mapred.JobID(parts[1], \n                                                    Integer.parseInt(parts[2]));\n        }\n      }\n    }catch (Exception ex) {//fall below\n    }\n    throw new IllegalArgumentException(\"JobId string : \" + str \n        + \" is not properly formed\");\n  }\n  \n}\n","sourceCodeStart":138,"sourceCodeEnd":161,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/JobID.java#L138-L161","documentation":"JobID.forName(String) parses canonical MapReduce job identifiers of the exact shape job_<jtIdentifier>_<id> (split on '_', exactly 3 parts, first part 'job', last part parseable by Integer.parseInt). The source swallows parse exceptions and falls through to IllegalArgumentException('JobId string : <str> is not properly formed'). It is the standard entry point when converting job-id strings from logs, paths, or RPC payloads back to a JobID.","triggerScenarios":"Passing a TaskID/TaskAttemptID string (task_.../attempt_...) which has 5-6 parts; passing a full staging path like /tmp/hadoop-yarn/staging/user/.staging/job_..._0001 instead of the id alone; trailing whitespace/newline from shell output; a non-numeric sequence number; a null-adjacent typo like 'job_2013041218000033' (only 2 parts).","commonSituations":"Log scrapers and MR output-parsing scripts that feed raw directory names into forName; automation piping `yarn application -list` output (appid format application_..., which is NOT a JobID) into JobID.forName; ids copied with quotes or whitespace.","solutions":["Extract only the last path component if the id came from a directory name: new Path(str).getName()","For attempt/task strings, parse the richer type first: TaskAttemptID.forName(s).getJobID() or TaskID.forName(s).getJobID()","Pre-validate with a regex like ^job_[^_]+_\\d+$ before calling forName","Remember yarn application ids (application_123_456) are not JobIDs — convert via the app report or use ApplicationId instead"],"exampleFix":"// before\nJobID id = JobID.forName(\"attempt_201304121800_0001_m_000003_0\"); // 6 parts -> throws\n\n// after\nJobID id = TaskAttemptID.forName(\"attempt_201304121800_0001_m_000003_0\").getJobID();\n// or from a staging path:\nJobID id2 = JobID.forName(new Path(stagingPath).getName());","handlingStrategy":"validation","validationCode":"// strict pre-check before JobID.forName\nprivate static final Pattern JOB_ID = Pattern.compile(\"^job_[^_/]+_\\\\d+$\");\n\nif (s == null || !JOB_ID.matcher(s).matches()) {\n  throw new IllegalArgumentException(\"Not a canonical JobID (expected job_<jtId>_<num>): \" + s);\n}\nJobID id = JobID.forName(s);","typeGuard":"static boolean isCanonicalJobId(String s) {\n  return s != null && s.startsWith(\"job_\") && s.split(\"_\").length == 3;\n}\n\n// usage: if (isCanonicalJobId(token)) { JobID id = JobID.forName(token); }","tryCatchPattern":"try {\n  JobID id = JobID.forName(raw.trim());\n} catch (IllegalArgumentException e) {\n  // message shape: 'JobId string : X is not properly formed'\n  log.warn(\"Skipping non-job token {}\", raw);\n}","preventionTips":["Trim input and take only the last path component for ids from directories","Convert attempt/task ids via TaskAttemptID/TaskID forName first","Never feed yarn application_ ids to JobID.forName — use ApplicationId APIs"],"tags":["job-id","parsing","argument-validation","mapreduce"],"backgroundTag":"id-parse-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}