{"record":{"id":"fce676545612c289","repo":"apache/hadoop","slug":"can-t-parse-mapname-list-entry-line","errorCode":null,"errorMessage":"Can't parse \" + mapName + \" list entry:\" + line","messagePattern":"Can't parse \" \\+ mapName \\+ \" list entry:\" \\+ line","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java","lineNumber":239,"sourceCode":"   * @throws IOException raised on errors performing I/O.\n   * @return updateMapInternal.\n   */\n  @VisibleForTesting\n  public static boolean updateMapInternal(BiMap<Integer, String> map,\n      String mapName, String command, String regex,\n      Map<Integer, Integer> staticMapping) throws IOException  {\n    boolean updated = false;\n    BufferedReader br = null;\n    try {\n      Process process = Runtime.getRuntime().exec(\n          new String[] { \"bash\", \"-c\", command });\n      br = new BufferedReader(\n          new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8));\n      String line = null;\n      while ((line = br.readLine()) != null) {\n        String[] nameId = line.split(regex);\n        if ((nameId == null) || (nameId.length != 2)) {\n          throw new IOException(\"Can't parse \" + mapName + \" list entry:\" + line);\n        }\n        LOG.debug(\"add to \" + mapName + \"map:\" + nameId[0] + \" id:\" + nameId[1]);\n        // HDFS can't differentiate duplicate names with simple authentication\n        final Integer key = staticMapping.get(parseId(nameId[1]));\n        final String value = nameId[0];\n        if (map.containsKey(key)) {\n          final String prevValue = map.get(key);\n          if (value.equals(prevValue)) {\n            // silently ignore equivalent entries\n            continue;\n          }\n          reportDuplicateEntry(\n              \"Got multiple names associated with the same id: \",\n              key, value, key, prevValue);           \n          continue;\n        }\n        if (map.containsValue(value)) {\n          final Integer prevKey = map.inverse().get(value);","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ShellBasedIdMapping.java#L221-L257","documentation":"ShellBasedIdMapping.updateMapInternal runs a shell command via 'bash -c' to dump users or groups (getent-style output), splits each line by a regex, and requires exactly two fields (name, id). Any line that does not split into exactly 2 parts throws IOException quoting the offending line, so the raw OS output can be inspected.","triggerScenarios":"The OS name service returns a malformed or unexpected line during map construction or incremental update: NIS/LDAP entries containing the separator in the name, wrapped or truncated getent output, or running the mapping on a platform whose tools do not emit standard passwd/group lines.","commonSituations":"NFS gateway / user-id mapping on hosts backed by NIS or LDAP with unusual entries; macOS or non-Linux dev machines where getent output differs; embedded environments with nonstandard bash/coreutils.","solutions":["Run the underlying dump manually ('getent passwd', 'getent group') on the node and locate the exact line shown in the exception","Fix or exclude the malformed name-service entry (rename users/groups containing ':' or whitespace)","For users/groups not present in the OS, use the static ID mapping file (IdMappingConstant.STATIC_ID_MAPPING_FILE_KEY, default /etc/nfs.static.map) instead of shell lookups","Run the gateway/mapping on a standard Linux host or upgrade Hadoop for platform-specific parsing fixes"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"Process p = new ProcessBuilder(\"bash\", \"-c\", \"getent passwd\").start();\n// pre-flight: confirm output lines split into exactly 2 fields before enabling the mapping\nBufferedReader r = new BufferedReader(\n    new InputStreamReader(p.getInputStream(), StandardCharsets.UTF_8));\nString line;\nwhile ((line = r.readLine()) != null) {\n  if (line.split(\":\").length != 7) { /* not standard passwd format */ }\n}","typeGuard":null,"tryCatchPattern":"try {\n  int uid = idMapping.getUid(user);\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Can't parse\")) {\n    // log the offending line included in the message and alert on name-service health\n  }\n  throw e;\n}","preventionTips":["Prefer static ID mapping files for users/groups not guaranteed in the OS","Run gateway nodes on standard Linux with predictable getent output","Audit passwd/group entries for separator characters when onboarding NIS/LDAP"],"tags":["unix","user-mapping","nfs","shell","parsing"],"backgroundTag":"shell-output-parse-failure","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}