I am seeing an intermittent issue where ES fails to execute a script due to an unsupported_operation_exception.
The whole error looks like this
"error": {
"type": "illegal_argument_exception",
"reason": "failed to execute script",
"caused_by": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"java.base/java.util.AbstractMap.put(AbstractMap.java:209)",
"ctx._source.groups.social = social;\n }\n}\n",
" ^---- HERE"
],
"script": "update-user",
"lang": "painless",
"position": {
"offset": 1744,
"start": 1723,
"end": 1794
},
"caused_by": {
"type": "unsupported_operation_exception",
"reason": "unsupported_operation_exception: null"
}
}
}
The line of code where the issue occurs is here:
if (ctx._source.groups == null) {
ctx._source.groups = [:]; // set groups to an empty map
}
ctx._source.groups.social = social;
I have tried many ways to reproduce this but have had no luck and I can't explain how unsupported_operation_exception is occurring.
One theory I have been trying to investigate is that the map is immutable so calling put() results in the unsupported_operation_exception. Is it possible for the map to be immutable and why would it be immutable in some cases and not others?
I have tried to use Debug.explain to show the painless_type of the field but it does not seem to work for maps.
Any insight would be greatly appreciated!