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 simulate returns a blank page when watcher execute API returns no execution result #177745

Closed
jguay opened this issue Feb 23, 2024 · 5 comments · Fixed by #178016
Closed
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Watcher Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more

Comments

@jguay
Copy link
Contributor

jguay commented Feb 23, 2024

Could not find if this 8.12 bug was known already (not reproducible in 7.17)

Kibana version:
8.12.1
Elasticsearch version:
8.12.1
Original install method (e.g. download page, yum, from source, etc.):
docker
Describe the bug:
When watcher execute fails, a blank page appear with javascript error because .watchHistoryItem.details.result.condition.met field does not exist in response from watcher execute API
Steps to reproduce:

  • Start a blank 8.12.1 system (no need to add data)
  • Create this watcher with invalid date_histogram parameter interval from watcher UI
{
  "trigger": {
    "schedule": {
      "interval": "10m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "test*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "size": "0",
          "query": {
            "match_all": {}
          },
          "aggs": {
            "dateHistogram": {
              "date_histogram": {
                "field": "@timestamp",
                "interval": "1m"
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "always": {}
  },
  "actions": {}
}
  • Select simulate - a blank page appear (screenshot provided)

Javascript console shows clear cause :

kbn-ui-shared-deps-npm.dll.js:425 TypeError: Cannot read properties of undefined (reading 'met')
    at ut (watcher.chunk.1.js:13:100156)
    at ua (kbn-ui-shared-deps-npm.dll.js:425:59279)
    at Za (kbn-ui-shared-deps-npm.dll.js:425:69022)
    at ec (kbn-ui-shared-deps-npm.dll.js:425:116164)
    at Pc (kbn-ui-shared-deps-npm.dll.js:425:99978)
    at Nc (kbn-ui-shared-deps-npm.dll.js:425:99800)
    at Dc (kbn-ui-shared-deps-npm.dll.js:425:99633)
    at wc (kbn-ui-shared-deps-npm.dll.js:425:96466)
    at kbn-ui-shared-deps-npm.dll.js:425:45201
    at t.unstable_runWithPriority (kbn-ui-shared-deps-npm.dll.js:433:3768)

And network tab shows request PUT kbn:/api/watcher/watch/execute returned this output with a 200 response code (there is no met field anywhere in the output from elasticsearch watcher execute API in this case because in this case the dateHistogram use interval which was deprecated in 7.2 and removed from 8.0)

{
    "watchHistoryItem": {
        "id": "_inlined__562b6a59-7276-4b58-aac6-a5ee7f2ee87f-2024-02-23T17:30:21.502683463Z",
        "watchId": "_inlined_",
        "details": {
            "watch_id": "_inlined_",
            "node": "f5M540OTQTCbRBauHozREg",
            "state": "failed",
            "@timestamp": "2024-02-23T17:30:21.502675088Z",
            "user": "elastic",
            "status": {
                "state": {
                    "active": true,
                    "timestamp": "2024-02-23T17:30:21.502Z"
                },
                "actions": {},
                "execution_state": "failed",
                "version": -1
            },
            "trigger_event": {
                "type": "manual",
                "triggered_time": "2024-02-23T17:30:21.502Z",
                "manual": {
                    "schedule": {
                        "scheduled_time": "2024-02-23T17:30:21.502Z"
                    }
                }
            },
            "input": {
                "search": {
                    "request": {
                        "search_type": "query_then_fetch",
                        "indices": [
                            "test*"
                        ],
                        "rest_total_hits_as_int": true,
                        "body": {
                            "size": "0",
                            "query": {
                                "match_all": {}
                            },
                            "aggs": {
                                "dateHistogram": {
                                    "date_histogram": {
                                        "field": "@timestamp",
                                        "interval": "1m"
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "condition": {
                "always": {}
            },
            "metadata": {
                "name": "test",
                "xpack": {
                    "type": "json"
                }
            },
            "result": {
                "execution_time": "2024-02-23T17:30:21.502Z",
                "execution_duration": 0,
                "input": {
                    "type": "search",
                    "status": "failure",
                    "error": {
                        "root_cause": [
                            {
                                "type": "x_content_parse_exception",
                                "reason": "[1:102] [date_histogram] unknown field [interval] did you mean [fixed_interval]?"
                            }
                        ],
                        "type": "x_content_parse_exception",
                        "reason": "[1:102] [date_histogram] unknown field [interval] did you mean [fixed_interval]?"
                    },
                    "search": {
                        "request": {
                            "search_type": "query_then_fetch",
                            "indices": [
                                "test*"
                            ],
                            "rest_total_hits_as_int": true,
                            "body": {
                                "size": "0",
                                "query": {
                                    "match_all": {}
                                },
                                "aggs": {
                                    "dateHistogram": {
                                        "date_histogram": {
                                            "field": "@timestamp",
                                            "interval": "1m"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "actions": []
            },
            "messages": [
                "failed to execute watch input"
            ]
        },
        "startTime": "2024-02-23T17:30:21.502Z",
        "watchStatus": {
            "id": "_inlined_",
            "isActive": true,
            "lastChecked": null,
            "lastMetCondition": null,
            "state": "Error",
            "comment": "",
            "actionStatuses": []
        }
    }
}

As note in 7.17 replacing interval with unknownparameter, watcher simulate UI in Kibana worked correctly returning the output of elasticsearch (no blank page and no javascript error)

Expected behavior:
Report some error in UI to improve handling of"execution_state": "failed" when .watchHistoryItem.details.result.condition.met is not in response body
Screenshots (if relevant):
Screenshot 2024-02-23 at 17 34 24

@jguay jguay added bug Fixes for quality problems that affect the customer experience Feature:Watcher labels Feb 23, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Feb 23, 2024
@lukasolson lukasolson added Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more and removed needs-team Issues missing a team label labels Mar 4, 2024
@elasticmachine
Copy link
Contributor

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

@nabil86
Copy link

nabil86 commented Mar 4, 2024

Same error on Kibana 8.10.4

@dantsyt
Copy link

dantsyt commented Mar 6, 2024

Same blank screen and error appears on null pointer exceptions in the condition script execution, in Kibana v 8.11.4

ElenaStoeva added a commit that referenced this issue Mar 6, 2024
Fixes #177745

## Summary

This PR fixes the bug in the simulate flyout which caused a blank page
when the watch execution returns no execution result. It also adds a
check for whether there is an execution result with the condition
property and only then displays the condition status under the title.

**How to test:**

1. Go to Stack Management -> Watcher
2. Start creating an advanced watch.
3. Add the following json in the editor (it contains an invalid
`interval` property in the `date_histogram` parameter):
```
{
  "trigger": {
    "schedule": {
      "interval": "10m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "test*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "size": "0",
          "query": {
            "match_all": {}
          },
          "aggs": {
            "dateHistogram": {
              "date_histogram": {
                "field": "@timestamp",
                "interval": "1m"
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "always": {}
  },
  "actions": {}
}
```
5. Click on the "Simulate" tab and then the "Simulate" button.
6. Verify the page doesn't crash and no condition met status is
displayed since the watch execution failed.
7. Start creating a new advanced watch, this time use the already
provided json, which is valid.
8. Click on Simulate and verify that the Condition met status is
displayed correctly - you can change the
`condition.compare.ctx.payload.hits.total.gte` property in the json to
`0` in order to see a "Condition met" status.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Mar 6, 2024
Fixes elastic#177745

## Summary

This PR fixes the bug in the simulate flyout which caused a blank page
when the watch execution returns no execution result. It also adds a
check for whether there is an execution result with the condition
property and only then displays the condition status under the title.

**How to test:**

1. Go to Stack Management -> Watcher
2. Start creating an advanced watch.
3. Add the following json in the editor (it contains an invalid
`interval` property in the `date_histogram` parameter):
```
{
  "trigger": {
    "schedule": {
      "interval": "10m"
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "test*"
        ],
        "rest_total_hits_as_int": true,
        "body": {
          "size": "0",
          "query": {
            "match_all": {}
          },
          "aggs": {
            "dateHistogram": {
              "date_histogram": {
                "field": "@timestamp",
                "interval": "1m"
              }
            }
          }
        }
      }
    }
  },
  "condition": {
    "always": {}
  },
  "actions": {}
}
```
5. Click on the "Simulate" tab and then the "Simulate" button.
6. Verify the page doesn't crash and no condition met status is
displayed since the watch execution failed.
7. Start creating a new advanced watch, this time use the already
provided json, which is valid.
8. Click on Simulate and verify that the Condition met status is
displayed correctly - you can change the
`condition.compare.ctx.payload.hits.total.gte` property in the json to
`0` in order to see a "Condition met" status.

(cherry picked from commit be634a3)
kibanamachine referenced this issue Mar 6, 2024
# Backport

This will backport the following commits from `main` to `8.13`:
- [[Watcher] Fix simulate flyout blank page
(#178016)](#178016)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Stoeva","email":"59341489+ElenaStoeva@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-03-06T20:18:52Z","message":"[Watcher]
Fix simulate flyout blank page (#178016)\n\nFixes
https://github.com/elastic/kibana/issues/177745\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in the simulate flyout which caused
a blank page\r\nwhen the watch execution returns no execution result. It
also adds a\r\ncheck for whether there is an execution result with the
condition\r\nproperty and only then displays the condition status under
the title.\r\n\r\n**How to test:**\r\n\r\n1. Go to Stack Management ->
Watcher\r\n2. Start creating an advanced watch.\r\n3. Add the following
json in the editor (it contains an invalid\r\n`interval` property in the
`date_histogram` parameter):\r\n```\r\n{\r\n \"trigger\": {\r\n
\"schedule\": {\r\n \"interval\": \"10m\"\r\n }\r\n },\r\n \"input\":
{\r\n \"search\": {\r\n \"request\": {\r\n \"search_type\":
\"query_then_fetch\",\r\n \"indices\": [\r\n \"test*\"\r\n ],\r\n
\"rest_total_hits_as_int\": true,\r\n \"body\": {\r\n \"size\":
\"0\",\r\n \"query\": {\r\n \"match_all\": {}\r\n },\r\n \"aggs\": {\r\n
\"dateHistogram\": {\r\n \"date_histogram\": {\r\n \"field\":
\"@timestamp\",\r\n \"interval\": \"1m\"\r\n }\r\n }\r\n }\r\n }\r\n
}\r\n }\r\n },\r\n \"condition\": {\r\n \"always\": {}\r\n },\r\n
\"actions\": {}\r\n}\r\n```\r\n5. Click on the \"Simulate\" tab and then
the \"Simulate\" button.\r\n6. Verify the page doesn't crash and no
condition met status is\r\ndisplayed since the watch execution
failed.\r\n7. Start creating a new advanced watch, this time use the
already\r\nprovided json, which is valid.\r\n8. Click on Simulate and
verify that the Condition met status is\r\ndisplayed correctly - you can
change the\r\n`condition.compare.ctx.payload.hits.total.gte` property in
the json to\r\n`0` in order to see a \"Condition met\"
status.","sha":"be634a33368e962596fcb144c06c27d31be3c15d","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Watcher","Team:Deployment
Management","release_note:skip","backport:prev-minor","v8.13.0","v8.14.0"],"title":"[Watcher]
Fix simulate flyout blank
page","number":178016,"url":"https://github.com/elastic/kibana/pull/178016","mergeCommit":{"message":"[Watcher]
Fix simulate flyout blank page (#178016)\n\nFixes
https://github.com/elastic/kibana/issues/177745\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in the simulate flyout which caused
a blank page\r\nwhen the watch execution returns no execution result. It
also adds a\r\ncheck for whether there is an execution result with the
condition\r\nproperty and only then displays the condition status under
the title.\r\n\r\n**How to test:**\r\n\r\n1. Go to Stack Management ->
Watcher\r\n2. Start creating an advanced watch.\r\n3. Add the following
json in the editor (it contains an invalid\r\n`interval` property in the
`date_histogram` parameter):\r\n```\r\n{\r\n \"trigger\": {\r\n
\"schedule\": {\r\n \"interval\": \"10m\"\r\n }\r\n },\r\n \"input\":
{\r\n \"search\": {\r\n \"request\": {\r\n \"search_type\":
\"query_then_fetch\",\r\n \"indices\": [\r\n \"test*\"\r\n ],\r\n
\"rest_total_hits_as_int\": true,\r\n \"body\": {\r\n \"size\":
\"0\",\r\n \"query\": {\r\n \"match_all\": {}\r\n },\r\n \"aggs\": {\r\n
\"dateHistogram\": {\r\n \"date_histogram\": {\r\n \"field\":
\"@timestamp\",\r\n \"interval\": \"1m\"\r\n }\r\n }\r\n }\r\n }\r\n
}\r\n }\r\n },\r\n \"condition\": {\r\n \"always\": {}\r\n },\r\n
\"actions\": {}\r\n}\r\n```\r\n5. Click on the \"Simulate\" tab and then
the \"Simulate\" button.\r\n6. Verify the page doesn't crash and no
condition met status is\r\ndisplayed since the watch execution
failed.\r\n7. Start creating a new advanced watch, this time use the
already\r\nprovided json, which is valid.\r\n8. Click on Simulate and
verify that the Condition met status is\r\ndisplayed correctly - you can
change the\r\n`condition.compare.ctx.payload.hits.total.gte` property in
the json to\r\n`0` in order to see a \"Condition met\"
status.","sha":"be634a33368e962596fcb144c06c27d31be3c15d"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/178016","number":178016,"mergeCommit":{"message":"[Watcher]
Fix simulate flyout blank page (#178016)\n\nFixes
https://github.com/elastic/kibana/issues/177745\r\n\r\n##
Summary\r\n\r\nThis PR fixes the bug in the simulate flyout which caused
a blank page\r\nwhen the watch execution returns no execution result. It
also adds a\r\ncheck for whether there is an execution result with the
condition\r\nproperty and only then displays the condition status under
the title.\r\n\r\n**How to test:**\r\n\r\n1. Go to Stack Management ->
Watcher\r\n2. Start creating an advanced watch.\r\n3. Add the following
json in the editor (it contains an invalid\r\n`interval` property in the
`date_histogram` parameter):\r\n```\r\n{\r\n \"trigger\": {\r\n
\"schedule\": {\r\n \"interval\": \"10m\"\r\n }\r\n },\r\n \"input\":
{\r\n \"search\": {\r\n \"request\": {\r\n \"search_type\":
\"query_then_fetch\",\r\n \"indices\": [\r\n \"test*\"\r\n ],\r\n
\"rest_total_hits_as_int\": true,\r\n \"body\": {\r\n \"size\":
\"0\",\r\n \"query\": {\r\n \"match_all\": {}\r\n },\r\n \"aggs\": {\r\n
\"dateHistogram\": {\r\n \"date_histogram\": {\r\n \"field\":
\"@timestamp\",\r\n \"interval\": \"1m\"\r\n }\r\n }\r\n }\r\n }\r\n
}\r\n }\r\n },\r\n \"condition\": {\r\n \"always\": {}\r\n },\r\n
\"actions\": {}\r\n}\r\n```\r\n5. Click on the \"Simulate\" tab and then
the \"Simulate\" button.\r\n6. Verify the page doesn't crash and no
condition met status is\r\ndisplayed since the watch execution
failed.\r\n7. Start creating a new advanced watch, this time use the
already\r\nprovided json, which is valid.\r\n8. Click on Simulate and
verify that the Condition met status is\r\ndisplayed correctly - you can
change the\r\n`condition.compare.ctx.payload.hits.total.gte` property in
the json to\r\n`0` in order to see a \"Condition met\"
status.","sha":"be634a33368e962596fcb144c06c27d31be3c15d"}}]}]
BACKPORT-->

Co-authored-by: Elena Stoeva <59341489+ElenaStoeva@users.noreply.github.com>
@chamakaleprattik
Copy link

Same error is kibana v8.12.2

@alisonelizabeth
Copy link
Contributor

Hi @chamakaleprattik this should be fixed as of 8.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Watcher Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants