{"record":{"id":"c654dfdf9ac66162","repo":"apache/hadoop","slug":"error-parsing-recovery-options-can-t-understand-o","errorCode":null,"errorMessage":"Error parsing recovery options: can't understand option \"{args[i]}\"","messagePattern":"Error parsing recovery options: can't understand option \"(.+?)\"","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java","lineNumber":1774,"sourceCode":"            startOpt.setForceFormat(true);\n          } else {\n            LOG.error(\"Invalid argument: \" + args[i]);\n            return null;\n          }\n        }\n        return startOpt;\n      } else if (StartupOption.RECOVER.getName().equalsIgnoreCase(cmd)) {\n        if (startOpt != StartupOption.REGULAR) {\n          throw new RuntimeException(\"Can't combine -recover with \" +\n              \"other startup options.\");\n        }\n        startOpt = StartupOption.RECOVER;\n        while (++i < argsLen) {\n          if (args[i].equalsIgnoreCase(\n                StartupOption.FORCE.getName())) {\n            startOpt.setForce(MetaRecoveryContext.FORCE_FIRST_CHOICE);\n          } else {\n            throw new RuntimeException(\"Error parsing recovery options: \" + \n              \"can't understand option \\\"\" + args[i] + \"\\\"\");\n          }\n        }\n      } else if (StartupOption.METADATAVERSION.getName().equalsIgnoreCase(cmd)) {\n        startOpt = StartupOption.METADATAVERSION;\n      } else {\n        return null;\n      }\n    }\n    return startOpt;\n  }\n\n  private static void setStartupOption(Configuration conf, StartupOption opt) {\n    conf.set(DFS_NAMENODE_STARTUP_KEY, opt.name());\n  }\n\n  public static StartupOption getStartupOption(Configuration conf) {\n    return StartupOption.valueOf(conf.get(DFS_NAMENODE_STARTUP_KEY,","sourceCodeStart":1756,"sourceCodeEnd":1792,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java#L1756-L1792","documentation":"In the '-recover' argument-parsing loop, the only accepted token is '-force' (mapped to MetaRecoveryContext.FORCE_FIRST_CHOICE). Any following token the parser does not recognize raises RuntimeException 'Error parsing recovery options' naming the offending option, so the NameNode refuses to start with a malformed recovery command line.","triggerScenarios":"'hdfs namenode -recover <token>' where <token> is anything but '-force' - e.g., '-recover -interactive', '-recover force' (missing dash), or a flag meant for another mode like '-recover -bootstrapStandby'.","commonSituations":"Typos or missing dashes in recovery flags; operators guessing at non-existent recovery options during an incident; scripts passing extra flags into the recover invocation.","solutions":["Use the exact supported form: 'hdfs namenode -recover -force' (force picks the first choice for every edit-log decision instead of prompting).","Remove every other token after '-recover'; if you needed another option, it belongs in a separate command.","Re-check the spelling of '-force' (case-insensitive per equalsIgnoreCase, but the dash is required)."],"exampleFix":"# before\nhdfs namenode -recover -interactive\n\n# after\nhdfs namenode -recover -force   # '-force' is the only option '-recover' accepts","handlingStrategy":"validation","validationCode":"# accept only the documented form\nif cmd == 'hdfs namenode -recover':\n    tail = args[args.index('-recover')+1:]\n    if any(a.lower() not in ('-force',) for a in tail):\n        abort(\"-recover accepts only -force\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the '-recover' grammar: only '-force' may follow it; everything else is an error.","Avoid guessing flags during incidents; check 'hdfs namenode -h' first.","Wrap recovery commands in scripts with argument whitelists so typos fail before the NN does."],"tags":["hdfs","namenode","cli","arguments","recovery"],"backgroundTag":"invalid-cli-arguments","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}