{"record":{"id":"2697f3b08fe942d6","repo":"apache/hadoop","slug":"unable-to-parse-line","errorCode":null,"errorMessage":"Unable to parse line: '{}'","messagePattern":"Unable to parse line: '(.+?)'","errorType":"exception","errorClass":"BadFencingConfigurationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/NodeFencer.java","lineNumber":162,"sourceCode":"        methods.add(parseMethod(conf, line));\n      }\n    }\n    \n    return methods;\n  }\n\n  private static FenceMethodWithArg parseMethod(Configuration conf, String line)\n      throws BadFencingConfigurationException {\n    Matcher m;\n    if ((m = CLASS_WITH_ARGUMENT.matcher(line)).matches()) {\n      String className = m.group(1);\n      String arg = m.group(2);\n      return createFenceMethod(conf, className, arg);\n    } else if ((m = CLASS_WITHOUT_ARGUMENT.matcher(line)).matches()) {\n      String className = m.group(1);\n      return createFenceMethod(conf, className, null);\n    } else {\n      throw new BadFencingConfigurationException(\n          \"Unable to parse line: '\" + line + \"'\");\n    }\n  }\n\n  private static FenceMethodWithArg createFenceMethod(\n      Configuration conf, String clazzName, String arg)\n      throws BadFencingConfigurationException {\n\n    Class<?> clazz;\n    try {\n      // See if it's a short name for one of the built-in methods\n      clazz = STANDARD_METHODS.get(clazzName);\n      if (clazz == null) {\n        // Try to instantiate the user's custom method\n        clazz = Class.forName(clazzName);\n      }\n    } catch (Exception e) {\n      throw new BadFencingConfigurationException(","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/NodeFencer.java#L144-L180","documentation":"NodeFencer.parseMethod() throws BadFencingConfigurationException(\"Unable to parse line: '<line>'\") when an entry of dfs.ha.fencing.methods matches neither CLASS_WITH_ARGUMENT ('class(arg)') nor CLASS_WITHOUT_ARGUMENT ('class'). The fencing configuration line is malformed, so no fencer can be built.","triggerScenarios":"Configuring dfs.ha.fencing.methods (one method per line) with a line containing whitespace, unbalanced/missing parentheses, an argument without parentheses, or stray characters — e.g. 'sshfence(hdfs :22)' (space), 'shell(/bin/true' (missing ')'), 'shell /bin/true' (no parens). The exception surfaces when the fencer is constructed (failover time or HA service init).","commonSituations":"Hand-edited hdfs-site.xml with typos; XML entity/quote mistakes; copy-paste of config snippets with placeholders or trailing spaces; multi-line value where one line is bad.","solutions":["Use exact syntax 'method(arg)' or 'method', one method per line, no spaces inside: e.g. 'sshfence(hdfs:22)' then a second line 'shell(/path/fence.sh)'.","Use built-in short names sshfence/shell, or a fully-qualified class name of a custom FenceMethod.","Validate the property value in hdfs-site.xml (matched parens, no stray whitespace), then restart the daemon — the error appears only when fencing is attempted, not at config load."],"exampleFix":"<!-- before: malformed lines -->\n<value>sshfence(hdfs :22)\nshell /usr/local/bin/fence-nn.sh</value>\n\n<!-- after: correct method(arg) syntax, one per line -->\n<value>sshfence(hdfs:22)\nshell(/usr/local/bin/fence-nn.sh)</value>","handlingStrategy":"validation","validationCode":"// Validate fencing method lines exactly as NodeFencer will parse them\nString methods = conf.get(\"dfs.ha.fencing.methods\", \"\");\nfor (String line : methods.split(\"\\n\")) {\n  if (!line.trim().matches(\"[\\\\w.$]+(\\\\([^()]*\\\\))?\")) {\n    throw new IllegalArgumentException(\"Bad fencing line: '\" + line + \"'\");\n  }\n}\n// Stronger: let Hadoop itself validate\nnew NodeFencer(conf, methods); // throws BadFencingConfigurationException on any bad line","typeGuard":null,"tryCatchPattern":"try {\n  new NodeFencer(conf, conf.get(\"dfs.ha.fencing.methods\"));\n} catch (BadFencingConfigurationException e) {\n  // surface the exact offending line in a config-check report at deploy time\n}","preventionTips":["Lint dfs.ha.fencing.methods in CI/deploy scripts: method(arg) or method, one per line, no spaces, matched parens.","Prefer the sshfence/shell built-ins to reduce the surface for typos.","Construct a NodeFencer in a post-deploy smoke test so config errors surface before a real failover needs them."],"tags":["hadoop","configuration","fencing","parse-error"],"backgroundTag":"config-parse-error","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}