Open
Description
Elasticsearch Version
8.11.1
Problem Description
Transform scripts raise the following exception instead of a more comprehensible error
"error": {
"root_cause": [
{
"type": "null_pointer_exception",
"reason": """Cannot invoke "org.elasticsearch.xpack.core.watcher.watch.Payload.data()" because the return value of "org.elasticsearch.xpack.core.watcher.input.Input$Result.payload()" is null"""
}
],
"type": "null_pointer_exception",
"reason": """Cannot invoke "org.elasticsearch.xpack.core.watcher.watch.Payload.data()" because the return value of "org.elasticsearch.xpack.core.watcher.input.Input$Result.payload()" is null"""
}
Steps to Reproduce
POST _watcher/watch/_execute?filter_path=*.result
{
"watch" : {
"trigger" : { "schedule" : { "interval" : "10s" } },
"input": {
"chain": {
"inputs": [
{
"example": {
"transform": {
"script": {
"source": "int d = ctx.execution_time.getDayOfWeek()"
}
}
}
}
]
}
}
}
}
POST _watcher/watch/_execute?filter_path=*.result
{
"watch" : {
"trigger" : { "schedule" : { "interval" : "10s" } },
"input": {
"chain": {
"inputs": [
{
"example": {
"transform": {
"script": {
"source": "def undef = null; undef.x"
}
}
}
}
]
}
}
}
}
Both return
{
"watch_record": {
"result": {
"execution_time": "2023-12-22T11:18:33.490Z",
"execution_duration": 2,
"input": {
"type": "chain",
"status": "failure",
"error": {
"root_cause": [
{
"type": "null_pointer_exception",
"reason": """Cannot invoke "org.elasticsearch.xpack.core.watcher.watch.Payload.data()" because the return value of "org.elasticsearch.xpack.core.watcher.input.Input$Result.payload()" is null"""
}
],
"type": "null_pointer_exception",
"reason": """Cannot invoke "org.elasticsearch.xpack.core.watcher.watch.Payload.data()" because the return value of "org.elasticsearch.xpack.core.watcher.input.Input$Result.payload()" is null"""
},
"chain": {}
},
"actions": []
}
}
}
instead of a class cast exception or a NPE with a better to understand reason.