Runtime fields can't be saved because highlighted errors need to be fixed but none are highlighted

The message says invalid Painless script but does not highlight any errors. Of course, I want to write a more involved script, but even this basic script is getting rejected without explanation.

Hi @rasmus.torkel and welcome to the community!

What version are you using?

Do you always see this error? Does it help to reopen the flyout or enter another script?

Thanks for replying. I am not sure there is a way to tell from the browser. I will ask my team to tell me the Kibana version.

I have tried creating a script from scratch multiple times and even restarted my laptop in between. I have seen this error in more complex scripts but I thought for asking the question, I'd make it as basic as I can, so that the correctness of the script is obvious.

I had actually saved at some point and then Kibana would not let me save anymore, even with the same code. Another team member has also reported that the script editor for runtime fields sometimes plays up.

I went into Stack Management and this is what it said: "Welcome to Stack Management 8.11.1". This must have been on my screen many times without me noticing.

So I gather 8.11.1 is the relevant version.

Thanks! As far as I know such issues were not reported for 8.11.1 before.

Would be great if you could paste script examples here as text too.

Does the same script work correctly when executed directly in DevTools? For example:

GET kibana*/_search
  "runtime_mappings": {
    "test": {
      "type": "keyword",
      "script": {

Here is the code:


I am getting familiar with the dev tools now.

Thanks for the script, Julia. I ran it in the Dev Tools Console. The following came back:

  "took": 8,
  "timed_out": false,
  "_shards": {
    "total": 0,
    "successful": 0,
    "skipped": 0,
    "failed": 0
  "hits": {
    "total": {
      "value": 0,
      "relation": "eq"
    "max_score": 0,
    "hits": []

Thanks, @rasmus.torkel ! You can check in the same way your scripts to verify that there are no syntax errors in them.

If the script works in DevTools, but you still have issues with saving it as a new runtime field in UI, can you please share your exact steps? Also, updating your browser might help.

Thanks Julia.

The steps are:

  • Go to stack management/data views

  • Select my data view

  • Click "Add field" button

  • Give the field a name but leave the type as "keyword"

  • Turn on "Set value" and enter script

  • Try to save (this is where it does not work)

I am running this version of Chrome: Version 124.0.6367.201 (Official Build) (64-bit)

The browser is managed by my organisation. I am not free to change it. However, if you told me the version is behind and I need to have at least version X, then I could try to convince the support people to upgrade.

Thanks! Your browser version looks good.

Do you see any errors in the browser console or in flyout under the script textarea? Or failed network requests?

The problem has magically gone away!!

I had suggested to the support people that they restart the ELK/Kibana system. I don't have an answer back as to whether they actually did it.

Don't close yet, please. Let's see if the joy lasts.

The error is back. Of course, I wanted to have a more fancy script. I added more stuff and again could not save. I deleted my variable and started again with the simple script I posted above. Same error.

There is a work around. For the documentId, put the _id of a field that you are planning to refer to. I managed to get my script done.

Thanks, Julia, for your assistance.

If not all documents have values for the field in question, then it's recommended to add a check for it in your script so the actual search does not fail. Example:

if (doc["message"].size() > 0) {
} else {
1 Like

Thanks for that pointer, Julia. But my problem was that I could not save, not that my script was running but failing.

I am happy for you to close the thread now.

My feedback to the team is that no matter what stupid mistake the user has made or what else is misaligned in the set-up, any software system should produce clear error messages when it can't do what it is asked to do. That way, the user can get their job done quickly and efficiently and the support/dev team has less work to do, solving these kind of issues.

Thanks for the feedback!

I created an issue in Github to improve UX [Data view field] Restore/improve validation message when navigating between documents via preview panel · Issue #183598 · elastic/kibana · GitHub