Skip to content

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

@elasticmachine

Description

@elasticmachine

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions