chia7712 commented on code in PR #20185: URL: https://github.com/apache/kafka/pull/20185#discussion_r2227425142
########## 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: It would be cool if `FeatureCommand` and `StorageTool` could leverage the exception from `fromVersionString`. After fixing KAFKA-19545, the `MetadataVersion.fromVersionString` will be used only by tools only, so it could throw `TerseFailure` instead of `IllegalArgumentException`, which could then be directly reused by tools. -- 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