# Watcher Error (Runtime error) | Elasticsearch

**URL:** <https://discuss.elastic.co/t/watcher-error-runtime-error-elasticsearch/197648>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [September 2, 2019, 6:51am UTC](https://discuss.elastic.co/t/watcher-error-runtime-error-elasticsearch/197648 "2019-09-02T06:51:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [September 2, 2019, 6:51am UTC](https://discuss.elastic.co/t/watcher-error-runtime-error-elasticsearch/197648/1 "2019-09-02T06:51:15Z")

</div>

Hi,

I am getting an error message, however when I check and read through my code, it should be returning as it should be.

// Output

> <https://gist.github.com/nhtrn/a3e5b5236914e9e290df4a0cd0ec9419>

Any help is greatly appreciated to help me identify where I went wrong  
Thanks!  
Nhung

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 2, 2019, 8:18am UTC](https://discuss.elastic.co/t/watcher-error-runtime-error-elasticsearch/197648/2 "2019-09-02T08:18:19Z")

</div>

Please take the time to read the end of the response you supplied. Especially the `exception` part. There is a so called `NullPointerException` mentioned for `ctx.payload.aggregations.nodes` - as you can see in `result.payload`, your search did not return any hits, so there are also no aggregation fields in the search response.

You need to cater for this case in the condition.

---

<div class="post-metadata">

**Author:** ![ntran](https://avatars.discourse-cdn.com/v4/letter/n/73ab20/32.png) [@ntran](https://discuss.elastic.co/u/ntran)\
**Post date:** [September 2, 2019, 10:31am UTC](https://discuss.elastic.co/t/watcher-error-runtime-error-elasticsearch/197648/3 "2019-09-02T10:31:51Z")

</div>

Yes, I should have

Thanks as always for your help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 30, 2019, 10:41am UTC](https://discuss.elastic.co/t/watcher-error-runtime-error-elasticsearch/197648/4 "2019-09-30T10:41:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
