Options validation error messages in non-interactive mode
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 65/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- java, spring-boot
- Lĩnh vực
- cli
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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!
- Ngôn ngữ chính
- Java
- Star
- 827
- Fork
- 405
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của spring-projects/spring-shell
-
NonInteractiveShellRunner, wrong exit value when Commands cannot be parsedCó thể đã có người làm @czpilar đã nhận 14 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
spring-projects/spring-shell#1391 · 2 bình luận ·
-
ShellInputProvider inputs are not consumed by `ComponentFlow`-based interactive components (e.g. `ConfirmationInput`, `StringInput`)Có thể đã có người làm @czpilar đã nhận 26 ngày trước. Đang mởtype/enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
spring-projects/spring-shell#1383 · 6 bình luận ·
-
Revisit dependency to reactorĐang mởarea/dependencies type/enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
spring-projects/spring-shell#1213 · 2 reaction ·
-
Revisit dependency to Spring MessagingCó thể đã có người làm @piotrooo đã nhận 300 ngày trước. Đang mởarea/dependencies type/enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
spring-projects/spring-shell#1205 · 1 bình luận ·
-
Spring CLI AI AgentĐang mởstatus/need-triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
spring-projects/spring-shell#1198 · 2 bình luận ·
Tất cả issue của spring-projects/spring-shell
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] dubbo.protocol.triple.max-message-size is only read from OS environment variablesCó thể đã có người làm @CCCLL đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
youngyangyang04/leetcode-master#3026 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
hierynomus/sshj#1070 ·
-
Typo in ExecutorTemplate.cacelAllFuturesCó thể đã có người làm @xgx2025 đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100