{"record":{"id":"25892cb785e75b92","repo":"apache/hadoop","slug":"no-argument-passed-to-shell-fencing-method","errorCode":null,"errorMessage":"No argument passed to 'shell' fencing method","messagePattern":"No argument passed to 'shell' fencing method","errorType":"exception","errorClass":"BadFencingConfigurationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java","lineNumber":75,"sourceCode":"\n  /** Length at which to abbreviate command in long messages */\n  private static final int ABBREV_LENGTH = 20;\n\n  /** Prefix for target parameters added to the environment */\n  private static final String TARGET_PREFIX = \"target_\";\n\n  /** Prefix for source parameters added to the environment */\n  private static final String SOURCE_PREFIX = \"source_\";\n\n  private static final String ARG_DELIMITER = \",\";\n\n  @VisibleForTesting\n  static Logger LOG = LoggerFactory.getLogger(ShellCommandFencer.class);\n\n  @Override\n  public void checkArgs(String args) throws BadFencingConfigurationException {\n    if (args == null || args.isEmpty()) {\n      throw new BadFencingConfigurationException(\n          \"No argument passed to 'shell' fencing method\");\n    }\n    // Nothing else we can really check without actually running the command\n  }\n\n  @Override\n  public boolean tryFence(HAServiceTarget target, String args) {\n    ProcessBuilder builder;\n    String cmd = parseArgs(target.getTransitionTargetHAStatus(), args);\n\n    if (!Shell.WINDOWS) {\n      builder = new ProcessBuilder(\"bash\", \"-e\", \"-c\", cmd);\n    } else {\n      builder = new ProcessBuilder(\"cmd.exe\", \"/c\", cmd);\n    }\n\n    setConfAsEnvVars(builder.environment());\n    addTargetInfoAsEnvVars(target, builder.environment());","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ShellCommandFencer.java#L57-L93","documentation":"ShellCommandFencer.checkArgs() throws BadFencingConfigurationException(\"No argument passed to 'shell' fencing method\") at fencer creation when the 'shell' entry in dfs.ha.fencing.methods has an empty or absent argument — there is no command to execute, so fencing is impossible.","triggerScenarios":"dfs.ha.fencing.methods contains exactly 'shell()' or 'shell' with an empty/blank parenthesized argument. checkArgs() runs when the NodeFencer is constructed, so this fails as soon as the fencer is initialized (HA daemon start or first failover).","commonSituations":"Config template copied with the placeholder never replaced; the command was deleted during editing; misunderstanding that 'shell' requires the command inside parentheses.","solutions":["Provide a real command: 'shell(/bin/true)' only for testing, or 'shell(/path/fence.sh)' with an actual fencing script.","Ensure the argument is not just whitespace — isEmpty() also triggers the exception.","Fix hdfs-site.xml and restart the daemon / retry failover."],"exampleFix":"<!-- before -->\n<value>shell()</value>\n\n<!-- after -->\n<value>shell(/usr/local/bin/fence-nn.sh)</value>","handlingStrategy":"validation","validationCode":"String line = \"shell\"; // or parse the arg out of 'shell(...)'\nString arg = line.equals(\"shell\") ? null : argInsideParens;\nif (arg == null || arg.trim().isEmpty()) {\n  throw new IllegalStateException(\"shell fencer needs a command argument\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  new NodeFencer(conf, \"shell()\");\n} catch (BadFencingConfigurationException e) {\n  // message 'No argument passed' -> supply the command in hdfs-site.xml\n}","preventionTips":["Never ship 'shell()' — always name a concrete command or script path.","Include dfs.ha.fencing.methods in config templates with real values, not placeholders.","Validate the full fencing config with a NodeFencer construction smoke test at deploy time."],"tags":["hadoop","configuration","fencing","shell","argument-missing"],"backgroundTag":"missing-config-argument","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}