elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.72k stars 8.14k forks source link

Calling the watcher Get watch API endpoint generate malformed json #152865

Open frconil opened 1 year ago

frconil commented 1 year ago

Elasticsearch Version

8.6.1

Installed Plugins

No response

Java Version

bundled

OS Version

ESS

Problem Description

When using the Get watch API endpoint to export current watches, the JSON generated may not pass validation in either Dev Tools or the Kibana watcher UI.

In particular, this happens in triple quoted strings (e.g. """ delimited strings) terminated by a single ". For instance this is a line being generated by the API output:

"query_string": {
  "query": """("term" OR "myotherterm") AND "condition" AND NOT "othercondition""""
}

This line will trigger in error in both dev tools or the watcher interface reporting it as invalid json.

this fixed line works:

"query_string": {
  "query": """("term" OR "myotherterm") AND "condition" AND NOT "othercondition" """
}

Steps to Reproduce

Create a watch where the query is delimited by """. Export this watch with:

GET _watcher/watch/<watch_id>

Try and import the content of the _source object with PUT _watcher/watch/<watch_id> {<source>}.

Logs (if relevant)

Untitled

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-data-management (Team:Data Management)

dakrone commented 1 year ago

I've transferred this to the Kibana repository, as Elasticsearch itself does not generate any JSON using triple-quotes ("""). I suspect this is something related to the Dev Console within Kibana.

elasticmachine commented 1 year ago

Pinging @elastic/platform-deployment-management (Team:Deployment Management)

ElenaStoeva commented 1 year ago

Might be related to https://github.com/elastic/kibana/issues/13528

elasticmachine commented 2 days ago

Pinging @elastic/kibana-management (Team:Kibana Management)