[Solved] Compile error when searching in discover, unexpected token ['<EOF>'] was expecting one of ['}']


(Chris) #1

Kibana was working just fine but now the below error appears each time I search in the "Discover" panel.
It appeard on version 5.3.0, I upgraded to 5.3.1 but still got the error.

Looking at the "script" in the error it seems that there is a } missing at the end.
I'm new to Kibana so I don't really know where this script is coming from or how to fix it...

Error: Request to Elasticsearch failed: {
    "error": {
        "root_cause": [{
            "type": "script_exception",
            "reason": "compile error",
            "script_stack": ["...  return \"no exception\";\n}", "                             ^---- HERE"],
            "script": "def message = doc['message.keyword'].value;\nif (doc['message.message'].value =~ /Caught exception in Exception Strategy/) {\n    int lastSlashIndex = path.lastIndexOf(':');\n    if (lastSlashIndex > 0) {\n    return path.substring(lastSlashIndex+1);\n} else {\n    return \"no exception\";\n}",
            "lang": "painless"
        }],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [{
            "shard": 0,
            "index": "filebeat-2017.05.01",
            "node": "-iVxCmFyRLK-KscU_yKuPA",
            "reason": {
                "type": "script_exception",
                "reason": "compile error",
                "script_stack": ["...  return \"no exception\";\n}", 
                                 "                             ^---- HERE"],
                "script": "def message = doc['message.keyword'].value;\nif (doc['message.message'].value =~ /Caught exception in Exception Strategy/) {\n    int lastSlashIndex = path.lastIndexOf(':');\n    if (lastSlashIndex > 0) {\n    return path.substring(lastSlashIndex+1);\n} else {\n    return \"no exception\";\n}",
                "lang": "painless",
                "caused_by": {
                    "type": "illegal_argument_exception",
                    "reason": "unexpected token ['<EOF>'] was expecting one of ['}']."
                }
            }
        }],
        "caused_by": {
            "type": "script_exception",
            "reason": "compile error",
            "script_stack": ["...  return \"no exception\";\n}",
                             "                             ^---- HERE"],
            "script": "def message = doc['message.keyword'].value;\nif (doc['message.message'].value =~ /Caught exception in Exception Strategy/) {\n    int lastSlashIndex = path.lastIndexOf(':');\n    if (lastSlashIndex > 0) {\n    return path.substring(lastSlashIndex+1);\n} else {\n    return \"no exception\";\n}",
            "lang": "painless",
            "caused_by": {
                "type": "illegal_argument_exception",
                "reason": "unexpected token ['<EOF>'] was expecting one of ['}']."
            }
        }
    },
    "status": 500
}
at http: //myserver:5601/bundles/kibana.bundle.js?v=14844:28:15872
    at Function.Promise.try(http: //myserver:5601/bundles/commons.bundle.js?v=14844:75:22403)
        at http: //myserver:5601/bundles/commons.bundle.js?v=14844:75:21773
        at Array.map(native) at Function.Promise.map(http: //myserver:5601/bundles/commons.bundle.js?v=14844:75:21728)
            at callResponseHandlers(http: //myserver:5601/bundles/kibana.bundle.js?v=14844:28:15484)
                at http: //myserver:5601/bundles/kibana.bundle.js?v=14844:28:3614
                at processQueue(http: //myserver:5601/bundles/commons.bundle.js?v=14844:38:23621)
                    at http: //myserver:5601/bundles/commons.bundle.js?v=14844:38:23888
                    at Scope.$eval(http: //myserver:5601/bundles/commons.bundle.js?v=14844:39:4619)

Script with a missing } at the end

def message = doc['message.keyword'].value;

if (doc['message.message'].value = ~/Caught exception in Exception Strategy/) {
    int lastSlashIndex = path.lastIndexOf(':');
    if (lastSlashIndex > 0) {
        return path.substring(lastSlashIndex + 1);
    } else {
        return "no exception";
    }

(Bhavya R M) #2

Hi,

Sorry am a bit lost here. Can you please post a screenshot of the error? I am trying to figure out where are you on Kibana and what are you trying to do?

Thanks,
Bhavya


(Chris) #3

There you go:


(Bhavya R M) #4

Hi Chris,

Sorry for the delay in getting back to you.
It looks like you might have created a scripted field which is not compiling correctly. Can you go to management - click on index pattern - filebeat and delete any scripted fields you may have created. This should ideally fix the error.

If you need to create scripted fields - here is the documentation on it.
https://www.elastic.co/guide/en/kibana/current/scripted-fields.html

Thanks,
Bhavya


(Chris) #5

That was exactly it.
Not sure how that script got created but I'll remember to look there if I run in similars errors again.

Thank you so much !!!


(system) #6

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