# \[script\_exception\] runtime error bad request

**URL:** <https://discuss.elastic.co/t/script-exception-runtime-error-bad-request/240397>\
**Category:** Kibana\
**Tags:** painless\
**Created:** [July 8, 2020, 4:11pm UTC](https://discuss.elastic.co/t/script-exception-runtime-error-bad-request/240397 "2020-07-08T16:11:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rob2020](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rob2020](https://discuss.elastic.co/u/rob2020)\
**Post date:** [July 8, 2020, 4:11pm UTC](https://discuss.elastic.co/t/script-exception-runtime-error-bad-request/240397/1 "2020-07-08T16:11:55Z")

</div>

Hi, I am new in Kibana .So I added a scripted field in one of the index pattern. I am pretty sure the code should work fine.

```auto
if (doc['message.keyword'].value.contains('errCode')) {
return "match";
}
return "No match";

```

When I previewed the results, it works fine. However, when I tried to view it in Discover, it said "error loading data, [script\_exception] runtime error".

```auto
Error: Bad Request
    at Fetch._callee3$ (http://localhost:5601/bundles/commons.bundle.js:3:4001197)
    at l (http://localhost:5601/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:288:970406)
    at Generator._invoke (http://localhost:5601/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:288:970159)
    at Generator.forEach.e.<computed> [as next] (http://localhost:5601/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:288:970763)
    at asyncGeneratorStep (http://localhost:5601/bundles/commons.bundle.js:3:3994720)
    at _next (http://localhost:5601/bundles/commons.bundle.js:3:3995031)

```

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [July 8, 2020, 9:30pm UTC](https://discuss.elastic.co/t/script-exception-runtime-error-bad-request/240397/2 "2020-07-08T21:30:17Z")

</div>

Hi bob

The error message you posted does not give us enough info to troubleshoot. Are you able to get any other error messages from your kibana or elasticsearch logs?

---

<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:** [August 5, 2020, 9:45pm UTC](https://discuss.elastic.co/t/script-exception-runtime-error-bad-request/240397/3 "2020-08-05T21:45:29Z")

</div>

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