{"record":{"id":"e86de6400f5c6571","repo":"apache/hadoop","slug":"unable-to-parse-user-and-ssh-port","errorCode":null,"errorMessage":"Unable to parse user and SSH port: {}","messagePattern":"Unable to parse user and SSH port: (.+?)","errorType":"exception","errorClass":"BadFencingConfigurationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java","lineNumber":246,"sourceCode":"  static class Args {\n    private static final Pattern USER_PORT_RE = Pattern.compile(\n      \"([^:]+?)?(?:\\\\:(\\\\d+))?\");\n\n    private static final int DEFAULT_SSH_PORT = 22;\n\n    String user;\n    int sshPort;\n    \n    public Args(String arg) \n        throws BadFencingConfigurationException {\n      user = System.getProperty(\"user.name\");\n      sshPort = DEFAULT_SSH_PORT;\n\n      // Parse optional user and ssh port\n      if (arg != null && !arg.isEmpty()) {\n        Matcher m = USER_PORT_RE.matcher(arg);\n        if (!m.matches()) {\n          throw new BadFencingConfigurationException(\n              \"Unable to parse user and SSH port: \"+ arg);\n        }\n        if (m.group(1) != null) {\n          user = m.group(1);\n        }\n        if (m.group(2) != null) {\n          sshPort = parseConfiggedPort(m.group(2));\n        }\n      }\n    }\n\n    private int parseConfiggedPort(String portStr)\n        throws BadFencingConfigurationException {\n      try {\n        return Integer.parseInt(portStr);\n      } catch (NumberFormatException nfe) {\n        throw new BadFencingConfigurationException(\n            \"Port number '\" + portStr + \"' invalid\");","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/SshFenceByTcpPort.java#L228-L264","documentation":"SshFenceByTcpPort.Args throws BadFencingConfigurationException('Unable to parse user and SSH port: <arg>') when the sshfence argument does not match USER_PORT_RE — pattern '([^:]+?)?(?:\\:(\\d+))?' i.e. an optional colon-free username and an optional colon-prefixed numeric port.","triggerScenarios":"An sshfence(...) entry whose argument has a non-numeric port, spaces, or multiple colons: 'sshfence(hdfs:twentyTwo)', 'sshfence(hdfs :22)', 'sshfence(root:22:33)'. Valid forms are 'sshfence()', 'sshfence(hdfs)', 'sshfence(:2022)', 'sshfence(hdfs:22)'.","commonSituations":"Putting a hostname in the argument (the target host comes from the service address, not this arg); user names containing ':' or '@'; placeholder text left in templated config; port written with whitespace or units.","solutions":["Use the exact form 'sshfence(<user>:<port>)' with a plain username and a decimal port, e.g. 'sshfence(hdfs:22)'.","Omit parts entirely ('sshfence(hdfs)' or 'sshfence(:2222)') rather than adding placeholders — user.name and port 22 are the defaults.","Remove all spaces and extra colons from the argument."],"exampleFix":"<!-- before: hostname wrongly placed in the arg, extra colon -->\n<value>sshfence(root@nn1:22)</value>\n\n<!-- after: username:port only; host is derived from the service address -->\n<value>sshfence(root:22)</value>","handlingStrategy":"validation","validationCode":"// Same rule as USER_PORT_RE: optional colon-free user, optional ':<digits>'\nif (arg != null && !arg.isEmpty() && !arg.matches(\"([^:]+?)?(?::(\\\\d+))?\")) {\n  throw new IllegalArgumentException(\"Bad sshfence arg: \" + arg);\n}","typeGuard":null,"tryCatchPattern":"try {\n  new NodeFencer(conf, \"sshfence(\" + arg + \")\");\n} catch (BadFencingConfigurationException e) {\n  // 'Unable to parse user and SSH port' -> fix arg to user:port form\n}","preventionTips":["Remember the sshfence arg is user:port only — never a hostname; the host is taken from the target service address.","Use the canonical 'sshfence(hdfs:22)' form or omit parts entirely.","Config-lint any line matching /sshfence\\(.*[:,\\s@].*\\)/ in deploy checks."],"tags":["hadoop","configuration","fencing","ssh","parse-error"],"backgroundTag":"config-parse-error","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}