-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't dump a stacktrace for invalid patterns when executing elasticse… #49744
Conversation
Pinging @elastic/es-core-features (:Core/Features/Watcher) |
fbb8825
to
9988aa8
Compare
@gaobinlong thanks for opening this! We discussed it and have some feedback. Would you be able to add an additional command line argument that will still allow someone to access the full stacktrace if needed? It would be off by default, but in place in the event more diagnostic information is needed. |
@dakrone OK, I will do that. |
@dakrone I have added -d(--detail) argument for elasticsearch-croneval, which can be used to print the stacktrace if the cron expression is not valid. Can you help to review the change? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for iterating on this @gaobinlong, I'll merge this soon.
The PR is related to #49642.
When executing elasticsearch-croneval tool, it throws an exception and prints the stacktrace if the cron pattern is not valid. The change in this PR is catching the exception and printing the detail message only.
Before this change, when executing elasticsearch-croneval with invalid cron patterns:
./bin/elasticsearch-croneval "*"
it prints:
Exception in thread "main" java.lang.IllegalArgumentException: invalid cron expression [*] at org.elasticsearch.xpack.core.watcher.support.Exceptions.illegalArgument(Exceptions.java:22) at org.elasticsearch.xpack.core.scheduler.Cron.<init>(Cron.java:275) at org.elasticsearch.xpack.core.scheduler.Cron.validate(Cron.java:792)
After this change, it prints:
ERROR: invalid cron expression [illegal cron expression format [java.lang.IllegalArgumentException: unexpected end of expression at pos [1].]]