DL1231 commented on code in PR #20185:
URL: https://github.com/apache/kafka/pull/20185#discussion_r2224215359


##########
core/src/main/scala/kafka/tools/StorageTool.scala:
##########
@@ -128,9 +128,21 @@ object StorageTool extends Logging {
       setIgnoreFormatted(namespace.getBoolean("ignore_formatted")).
       setControllerListenerName(config.controllerListenerNames.get(0)).
       setMetadataLogDirectory(config.metadataLogDir)
-    Option(namespace.getString("release_version")).foreach(
-      releaseVersion => formatter.
-        setReleaseVersion(MetadataVersion.fromVersionString(releaseVersion)))
+
+    def metadataVersionsToString(first: MetadataVersion, last: 
MetadataVersion): String = {
+      val versions = MetadataVersion.VERSIONS.slice(first.ordinal, 
last.ordinal + 1)
+      versions.map(_.toString).mkString(", ")
+    }
+    Option(namespace.getString("release_version")).foreach(releaseVersion => {
+      try {
+        
formatter.setReleaseVersion(MetadataVersion.fromVersionString(releaseVersion))
+      } catch {
+        case _: Throwable =>
+          throw new TerseFailure(s"Unknown metadata.version $releaseVersion. 
Supported metadata.version are " +
+            s"${metadataVersionsToString(MetadataVersion.MINIMUM_VERSION, 
MetadataVersion.latestProduction())}")

Review Comment:
   Good catch! Thanks for the review.
   See the discussion:
    https://github.com/apache/kafka/pull/18845#discussion_r1950706791
   `MetadataVersion.fromVersionString` is just used to convert `String` to 
`MetadataVersion`. Perhaps the config `unstable.feature.versions.enable` shoule 
be considered when outputting error message. What do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to