Options validation error messages in non-interactive mode
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 65/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- java, spring-boot
- 領域
- cli
調査の方向性
Start with NonInteractiveShellRunner, which appears in the reported stack trace, and inspect how validation failures become CommandExecutionException messages. The related customization points named in the issue are CommandExceptionResolver and CommandCatalogCustomizer; done means non-interactive validation exposes the validator's message instead of only USAGE_ERROR, with stack-trace suppression considered separately.
索引モデルが issue の本文から書いたものです。
説明
Using Spring Shell 4.0.3 with Spring Boot 4.0.8, non-interactive mode (spring.shell.interactive.enabled=false).
When I add Bean Validation constraints to my @Options, and I start my application by specifying an argument which does not satisfy them, I get a very generic message, which does not explain at all what went wrong:
2026-10-02T16:45:29.372+02:00 ERROR 15460 --- [MyApp] [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.shell.core.command.CommandExecutionException: Unable to execute command plan -n testGen -c 0: USAGE_ERROR
at org.springframework.shell.core.NonInteractiveShellRunner.executeCommand(NonInteractiveShellRunner.java:162) ~[spring-shell-core-4.0.3.jar:4.0.3]
at org.springframework.shell.core.NonInteractiveShellRunner.run(NonInteractiveShellRunner.java:95) ~[spring-shell-core-4.0.3.jar:4.0.3]
at org.springframework.shell.core.autoconfigure.ShellRunnerAutoConfiguration.lambda$springShellApplicationRunner$0(ShellRunnerAutoConfiguration.java:39) ~[spring-shell-core-autoconfigure-4.0.3.jar:4.0.3]
at org.springframework.boot.SpringApplication.lambda$callRunner$0(SpringApplication.java:788) ~[spring-boot-4.0.8.jar:4.0.8]
at org.springframework.util.function.ThrowingConsumer$1.acceptWithException(ThrowingConsumer.java:82) ~[spring-core-7.0.9.jar:7.0.9]
at org.springframework.util.function.ThrowingConsumer.accept(ThrowingConsumer.java:60) ~[spring-core-7.0.9.jar:7.0.9]
at org.springframework.util.function.ThrowingConsumer$1.accept(ThrowingConsumer.java:86) ~[spring-core-7.0.9.jar:7.0.9]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) ~[spring-boot-4.0.8.jar:4.0.8]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:788) ~[spring-boot-4.0.8.jar:4.0.8]
at org.springframework.boot.SpringApplication.lambda$callRunners$0(SpringApplication.java:776) ~[spring-boot-4.0.8.jar:4.0.8]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[na:na]
at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:776) ~[spring-boot-4.0.8.jar:4.0.8]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:328) ~[spring-boot-4.0.8.jar:4.0.8]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1365) ~[spring-boot-4.0.8.jar:4.0.8]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-4.0.8.jar:4.0.8]
at example.MyApp.main(MyApp.java:31) ~[classes/:na]
In this case, I was specifying -c 0 while that option has @Min(1).
I would expect in some way to get the contents of the validation error message, as specified on the @Min annotation. Or, more generically, the error message supplied by the validator (in case custom error messages are built by my custom validator).
Asking AI, it suggests a quite complex customization through either CommandCatalogCustomizer or CommandExceptionResolver, which anyway requires to unwrap and inspect the ConstraintViolationException. Isn't there a built-in way to do this?
The default behavior I'm seeing seems to fully defeat the purpose of using the Bean Validation API.
Also suppressing the full stack trace would be nice, however, at least seeing the actual message (even if buried in the stack trace) would be better than nothing. What I'm trying to do is to write a command-line interface fro my Spring Boot app. Thanks!
- 主要言語
- Java
- スター
- 826
- フォーク
- 404
- 平均マージ
- 6日 9時間
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
spring-projects/spring-shell のほかの issue
-
NonInteractiveShellRunner, wrong exit value when Commands cannot be parsed対応中かも @czpilar が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
spring-projects/spring-shell#1391 · コメント 2 件 ·
-
ShellInputProvider inputs are not consumed by `ComponentFlow`-based interactive components (e.g. `ConfirmationInput`, `StringInput`)対応中かも @czpilar が 15 日前に担当しました。 オープンtype/enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
spring-projects/spring-shell#1383 · コメント 6 件 ·
-
area/dependencies type/enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
spring-projects/spring-shell#1213 · リアクション 1 件 ·
-
Revisit dependency to Spring Messaging対応中かも @piotrooo が 289 日前に担当しました。 オープンarea/dependencies type/enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
spring-projects/spring-shell#1205 · コメント 1 件 ·
-
Spring CLI AI Agentオープンstatus/need-triage
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
spring-projects/spring-shell#1198 · コメント 2 件 ·
spring-projects/spring-shell の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NationalSecurityAgency/ghidra#9748 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
spring-mcp-tools
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
explyt/spring-plugin#591 ·
メンテナーはふだん 1 日以内に返信
-
waiting-for-triage
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
spring-cloud/spring-cloud-openfeign#1443 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
ADORSYS-GIS/keycloak-oid4vp-plugin#221 ·
メンテナーはふだん 2 日以内に返信