# Upgrade to 7.2 causes shards failed due to painless script error

**URL:** <https://discuss.elastic.co/t/upgrade-to-7-2-causes-shards-failed-due-to-painless-script-error/188650>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [July 3, 2019, 8:36am UTC](https://discuss.elastic.co/t/upgrade-to-7-2-causes-shards-failed-due-to-painless-script-error/188650 "2019-07-03T08:36:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![C\_J](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/c_j/32/44969_2.png) [@C\_J](https://discuss.elastic.co/u/C_J)\
**Post date:** [July 3, 2019, 8:36am UTC](https://discuss.elastic.co/t/upgrade-to-7-2-causes-shards-failed-due-to-painless-script-error/188650/1 "2019-07-03T08:36:22Z")

</div>

Could anyone with more knowledge of painless could help me with a problem I have right now:  
After upgrading Stack to 7.2, in one of the visualization that is using Scripted field, I get **shards failed** error, it used to work before upgrade.

the painless code that used to work in 6.5:

```
if (!doc.containsKey('data.AudioPath.keyword') || doc['data.AudioPath.keyword'].value == null){ return ""; } return "https://xxx/" + doc['data.AudioPath.keyword'].value;

```

and verified that data is correctly passed as type **String** :

```
"_source" : {
      "data" : {
        ...
        "AudioPath" : "08035264-9d60-11e9-a23a-8c0f6f7c1ae2.wav"
      },

```

Here's the message in POST response:

```
script_stack: ["org.elasticsearch.index.fielddata.ScriptDocValues$Strings.get(ScriptDocValues.java:496)",…]
2: "if (!doc.containsKey('data.AudioPath.keyword') || doc['data.AudioPath.keyword'].value == null){ "
3: " ^---- HERE"

```

and also:

```
caused_by: {type: "illegal_state_exception",…}
reason: "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"

```

I went through documentation before upgrade and nowhere I found any statement of breaking changes in Painless Language...

---

<div class="post-metadata">

**Author:** ![C\_J](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/c_j/32/44969_2.png) [@C\_J](https://discuss.elastic.co/u/C_J)\
**Post date:** [July 3, 2019, 9:40am UTC](https://discuss.elastic.co/t/upgrade-to-7-2-causes-shards-failed-due-to-painless-script-error/188650/2 "2019-07-03T09:40:08Z")

</div>

resolved using doc['data.AudioPath.keyword'].empty

I don't think it's documented as a breaking change anywhere.

---

<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:** [July 3, 2019, 1:17pm UTC](https://discuss.elastic.co/t/upgrade-to-7-2-causes-shards-failed-due-to-painless-script-error/188650/3 "2019-07-03T13:17:40Z")

</div>

Hey,

it is mentioned here: [https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#\_accessing\_missing\_document\_values\_will\_throw\_an\_error](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-7.0.html#_accessing_missing_document_values_will_throw_an_error)

Also, if you upgrade to 6.8 before going to 7 there should have been a log message in the depreciation log (one of the reasons why it makes sense to get to the latest 6.x release first).

Is there anything we could have done to improve the docs regarding your issue? If so, happy to hear!

Hope this helps.

--Alex

---

<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:** [July 31, 2019, 1:17pm UTC](https://discuss.elastic.co/t/upgrade-to-7-2-causes-shards-failed-due-to-painless-script-error/188650/4 "2019-07-31T13:17:41Z")

</div>

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