# Cannot set property on null object

**URL:** <https://discuss.elastic.co/t/cannot-set-property-on-null-object/40781>\
**Category:** Elasticsearch\
**Created:** [February 2, 2016, 7:15pm UTC](https://discuss.elastic.co/t/cannot-set-property-on-null-object/40781 "2016-02-02T19:15:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tesseract](https://avatars.discourse-cdn.com/v4/letter/t/bb73d2/32.png) [@tesseract](https://discuss.elastic.co/u/tesseract)\
**Post date:** [February 2, 2016, 7:15pm UTC](https://discuss.elastic.co/t/cannot-set-property-on-null-object/40781/1 "2016-02-02T19:15:57Z")

</div>

Hey guys,  
I'm seeing this error on some of the document updates.

_{Reason: failed to execute script, Caused by: {"caused\_by":{"reason":"Cannot set property 'viewed' on null object","type":"null\_pointer\_exception"},"reason":"failed to run inline script [ctx.\_source.views[index]['viewed'] = true; ctx.\_source.views[index]['viewed\_time'] = view\_time] using lang [groovy]","type":"groovy\_script\_execution\_exception"}}_

I'm trying to modify the following document which exists in database(Index: view-2016-2-2\_18, Type: 16, Id: 14544394458810440750)

{  
"\_index": "view-2016-2-2\_18",  
"\_type": "16",  
"\_id": "14544394458810440750",  
"\_version": 2,  
"\_ttl": 85682770,  
"found": true,  
"\_source": {  
"id": "1-0-1454439445881044075",  
"isExternal": true,  
"networkId": "16",  
"currency": "",  
"received": "2016-02-02T18:57:25.881044075Z",  
"responsed": "2016-02-02T18:57:25.883277647Z",  
"response\_time": 2233572,  
"status\_code": 2,  
"views": [{  
"view-id": 0,  
"viewed": true,  
"view\_time": 1454439445883546015  
}],  
"site-id": "2791",  
"site-language": "en",  
"device-language": "en",  
"device-ip": "[XXX.XXX.XXX.XXX](http://XXX.XXX.XXX.XXX)",  
"device-os": "Windows 7",  
"device-country": "US",  
"device-region": "WI",  
"device-city": "Madison",  
"device-computed-type": "desktop",  
"device-computed-os": "windows",  
"device-location": "43.0761,-89.41",  
"user-id": "XYZXYZXYZXYZXYZ"  
}  
}

It doesn't seem to fail in all cases, but there are intermittent fails from time to time (around 5-10%). Anyone know what's possibly causing this error?

---

<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 5, 2017, 11:19pm UTC](https://discuss.elastic.co/t/cannot-set-property-on-null-object/40781/2 "2017-07-05T23:19:28Z")

</div>


