{"record":{"id":"7b21f47500291f17","repo":"apache/hadoop","slug":"failed-to-convert-to-rollingupgradeaction","errorCode":null,"errorMessage":"Failed to convert \"{}\" to RollingUpgradeAction","messagePattern":"Failed to convert \"(.+?)\" to RollingUpgradeAction","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java","lineNumber":411,"sourceCode":"            out.println(info);\n        } else if (!info.isFinalized()) {\n          out.println(\"Proceed with rolling upgrade:\");\n          out.println(info);\n        } else {\n          out.println(\"Rolling upgrade is finalized.\");\n          out.println(info);\n        }\n      } else {\n        out.println(\"There is no rolling upgrade in progress or rolling \" +\n            \"upgrade has already been finalized.\");\n      }\n    }\n\n    static int run(DistributedFileSystem dfs, String[] argv, int idx) throws IOException {\n      final RollingUpgradeAction action = RollingUpgradeAction.fromString(\n          argv.length >= 2? argv[1]: \"\");\n      if (action == null) {\n        throw new IllegalArgumentException(\"Failed to convert \\\"\" + argv[1]\n            +\"\\\" to \" + RollingUpgradeAction.class.getSimpleName());\n      }\n\n      System.out.println(action + \" rolling upgrade ...\");\n\n      final RollingUpgradeInfo info = dfs.rollingUpgrade(action);\n      switch(action){\n      case QUERY:\n        break;\n      case PREPARE:\n        Preconditions.checkState(info.isStarted());\n        break;\n      case FINALIZE:\n        Preconditions.checkState(info == null || info.isFinalized());\n        break;\n      }\n      printMessage(info, System.out);\n      return 0;","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java#L393-L429","documentation":"Argument parser for `hdfs dfsadmin -rollingUpgrade <action>`. RollingUpgradeAction.fromString uppercases the input and looks it up in a map that contains only QUERY, PREPARE, FINALIZE — plus the empty string, which maps to QUERY. An unrecognized action returns null and DFSAdmin throws IllegalArgumentException('Failed to convert \"<action>\" to RollingUpgradeAction'). Omitting the action entirely defaults to query and does NOT hit this error; only genuinely invalid strings do.","triggerScenarios":"hdfs dfsadmin -rollingUpgrade status ('status' is not an action); typos like prepair/finalise; scripts forwarding an arbitrary subcommand from a wrapper (e.g. a tool that accepts 'start' as a synonym).","commonSituations":"Operators expecting `-rollingUpgrade start`/`stop` semantics from other rolling-restart tools; help text written from memory instead of `hdfs dfsadmin -help rollingUpgrade`; wrapper scripts that pass through user input unvalidated.","solutions":["Use one of: hdfs dfsadmin -rollingUpgrade query | prepare | finalize (case-insensitive; empty means query)","Check the exact vocabulary: hdfs dfsadmin -help rollingUpgrade","Whitelist-validate the action in wrapper scripts before invoking dfsadmin","Map wrapper synonyms explicitly: start->prepare, status->query, done->finalize"],"exampleFix":"# before\n$ hdfs dfsadmin -rollingUpgrade status\n# IllegalArgumentException: Failed to convert \"status\" to RollingUpgradeAction\n\n# after\n$ hdfs dfsadmin -rollingUpgrade query","handlingStrategy":"validation","validationCode":"static final Set<String> ROLLING_UPGRADE_ACTIONS = Set.of(\"QUERY\", \"PREPARE\", \"FINALIZE\");\n\nstatic void validateAction(String a) {\n  if (!ROLLING_UPGRADE_ACTIONS.contains(a.toUpperCase(Locale.ROOT)))\n    throw new IllegalArgumentException(\"rollingUpgrade action must be query|prepare|finalize, got: \" + a);\n}","typeGuard":"static boolean isRollingUpgradeAction(String s) {\n  return s != null && ROLLING_UPGRADE_ACTIONS.contains(s.toUpperCase(Locale.ROOT));\n}","tryCatchPattern":null,"preventionTips":["Whitelist the three actions in wrapper scripts; map synonyms (start->prepare, status->query) explicitly","Run hdfs dfsadmin -help rollingUpgrade when in doubt about vocabulary","Treat any new subcommand name as a wrapper-level feature, not a dfsadmin passthrough"],"tags":["hdfs","dfsadmin","rolling-upgrade","cli","argument-parsing","enum-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}