{"record":{"id":"9677075f6623fe79","repo":"apache/hadoop","slug":"failed-to-convert-s-to-rollingupgradestartup","errorCode":null,"errorMessage":"Failed to convert \\\"{s}\\\" to RollingUpgradeStartupOption","messagePattern":"Failed to convert \\\\\"(.+?)\\\\\" to RollingUpgradeStartupOption","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HdfsServerConstants.java","lineNumber":123,"sourceCode":"    }\n\n    private static final RollingUpgradeStartupOption[] VALUES = values();\n\n    static RollingUpgradeStartupOption fromString(String s) {\n      if (\"downgrade\".equalsIgnoreCase(s)) {\n        throw new IllegalArgumentException(\n            \"The \\\"downgrade\\\" option is no longer supported\"\n                + \" since it may incorrectly finalize an ongoing rolling upgrade.\"\n                + \" For downgrade instruction, please see the documentation\"\n                + \" (http://hadoop.apache.org/docs/current/hadoop-project-dist/\"\n                + \"hadoop-hdfs/HdfsRollingUpgrade.html#Downgrade).\");\n      }\n      for(RollingUpgradeStartupOption opt : VALUES) {\n        if (opt.name().equalsIgnoreCase(s)) {\n          return opt;\n        }\n      }\n      throw new IllegalArgumentException(\"Failed to convert \\\"\" + s\n          + \"\\\" to \" + RollingUpgradeStartupOption.class.getSimpleName());\n    }\n\n    public static String getAllOptionString() {\n      final StringBuilder b = new StringBuilder(\"<\");\n      for(RollingUpgradeStartupOption opt : VALUES) {\n        b.append(StringUtils.toLowerCase(opt.name())).append(\"|\");\n      }\n      b.setCharAt(b.length() - 1, '>');\n      return b.toString();\n    }\n  }\n\n  /** Startup options */\n  enum StartupOption{\n    FORMAT  (\"-format\"),\n    CLUSTERID (\"-clusterid\"),\n    GENCLUSTERID (\"-genclusterid\"),","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/HdfsServerConstants.java#L105-L141","documentation":"RollingUpgradeStartupOption.fromString throws IllegalArgumentException for any string that is not (case-insensitively) a name of the enum, whose only members are ROLLBACK and STARTED (HdfsServerConstants.java:94-95). getAllOptionString() renders the accepted set as <rollback|started>. This is the NameNode startup option surface, distinct from 'hdfs dfsadmin -rollingUpgrade' verbs (query/prepare/finalize).","triggerScenarios":"Running 'hdfs namenode -rollingUpgrade <value>' where <value> is a typo or a dfsadmin verb such as 'query', 'prepare' or 'finalize', which do not exist in this enum; any programmatic call of fromString with an unvalidated string.","commonSituations":"Confusing the dfsadmin rollingUpgrade subcommands with the NameNode -rollingUpgrade startup options; typos in hand-written upgrade scripts; option drift across Hadoop versions.","solutions":["Use one of the valid NameNode startup options: 'hdfs namenode -rollingUpgrade rollback' or '-rollingUpgrade started'","If you meant query/prepare/finalize, run those via 'hdfs dfsadmin -rollingUpgrade <query|prepare|finalize>' instead","Validate the option string against RollingUpgradeStartupOption.getAllOptionString() output before starting the NameNode"],"exampleFix":"# before\nhdfs namenode -rollingUpgrade prepare   # not a startup option\n\n# after\nhdfs dfsadmin -rollingUpgrade prepare    # dfsadmin verb\nhdfs namenode -rollingUpgrade started    # valid startup option","handlingStrategy":"validation","validationCode":"private static final Set<String> VALID_RU_OPTIONS =\n    Set.of(\"rollback\", \"started\");\n\nboolean ok = VALID_RU_OPTIONS.contains(opt.toLowerCase(Locale.ROOT));\nif (!ok) throw new IllegalArgumentException(\n    \"Invalid -rollingUpgrade option: \" + opt + \"; expected <rollback|started>\");","typeGuard":"static boolean isSupportedRollingUpgradeOption(String s) {\n  return s != null && Arrays.stream(RollingUpgradeStartupOption.values())\n      .anyMatch(o -> o.name().equalsIgnoreCase(s));\n}","tryCatchPattern":"try {\n  return RollingUpgradeStartupOption.fromString(s);\n} catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Bad rollingUpgrade option '\" + s + \"'. Valid: \"\n      + RollingUpgradeStartupOption.getAllOptionString(), e);\n}","preventionTips":["Don't confuse NameNode -rollingUpgrade options (rollback|started) with dfsadmin verbs (query|prepare|finalize)","Whitelist option strings in scripts instead of passing user input straight through","Print getAllOptionString() in usage text of any wrapper tool"],"tags":["hdfs","rolling-upgrade","namenode","cli","invalid-argument"],"backgroundTag":"invalid-cli-option","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}