-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Watcher: Putting invalid JSON as a watch is allowed #29746
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
Comments
Currently, watches may be submitted and accepted by the cluster that do not consist of valid JSON. This is because in certain cases, WatchParser.java will not consume enough tokens from XContentParser to be able to encounter an underlying JSON parse error. This patch fixes this behavior and adds a test. Closes elastic#29746
Can an API endpoint be provided that validates a given watch configuration as well? We have a CI process for ingesting new watches into Elastic, and there's no linting tools, JSONschema, or anything available to validate common issues. |
can you be more specific what you mean with watch configuration in this context? The watch gets parsed, scripts get compiled to see if everything works, what validation are you missing? Would your problems be solved, when this issue is fixed or is there more to it? Thanks for your input, much appreciated! |
If I can supply the watch to the execute API without saving it to the index, and get back a detailed account of what's wrong, then that would solve the issue for me |
@spinscale What's the actual contract with the watch API? How do I determine programmatically that there's a problem? Looking at the Elastic documentation, I can't seem to find any examples or concrete description (other than eyeballing the results -- a Jenkins job doesn't have eyes) of how to do this. |
This has been open for quite a while, and hasn't had a lot of interest. For now I'm going to close this as something we aren't planning on implementing. We can re-open it later if needed. |
Original comment by @spinscale:
Putting a watch with invalid JSON does not return an error and puts a broken watch into the system. The Watch parser seems to have an issue here - which should throw an exception but does not.
Putting the below watch results in a watch stored without condition and actions.. you can use the execution watch API to see that an
always
condition is used and the actions array is empty.This issue happens on 2.x as well as 5.x
Originating issue was in the forum https://discuss.elastic.co/t/mistake-on-configuring-watches/70943/5
The text was updated successfully, but these errors were encountered: