Skip to content
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

Watcher: Putting invalid JSON as a watch is allowed #29746

Closed
elasticmachine opened this issue Feb 10, 2017 · 5 comments
Closed

Watcher: Putting invalid JSON as a watch is allowed #29746

elasticmachine opened this issue Feb 10, 2017 · 5 comments
Assignees
Labels

Comments

@elasticmachine
Copy link
Collaborator

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.

curl -XPUT localhost:9200/_xpack/watcher/watch/1 -d '
{
  "trigger": {
    "schedule": {
      "interval": "10s"
    }
  },
  "input": {
    "simple": {}
  }},
  "condition": {
    "script": {
      "inline": "return false"
    }
  },
  "actions": {
    "logging": {
      "logging": {
        "text": "{{ctx.payload}}"
      }
    }
  }
}'

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

tomcallahan pushed a commit to tomcallahan/elasticsearch that referenced this issue May 17, 2018
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
@tomcallahan tomcallahan self-assigned this May 17, 2018
@jcmcken
Copy link

jcmcken commented Jul 25, 2018

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.

@spinscale
Copy link
Contributor

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!

@jcmcken
Copy link

jcmcken commented Jul 26, 2018

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

@jcmcken
Copy link

jcmcken commented Aug 2, 2018

@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.

@rjernst rjernst added the Team:Data Management Meta label for data/management team label May 4, 2020
@dakrone
Copy link
Member

dakrone commented May 8, 2024

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.

@dakrone dakrone closed this as not planned Won't fix, can't repro, duplicate, stale May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants