Skip to content

Watcher: Scripting does not allow use of DateTime objects anymore #35913

Closed
@spinscale

Description

@spinscale

Elasticsearch version (bin/elasticsearch --version): 6.5.1

Description of the problem including expected versus actual behavior:

Steps to reproduce:

POST _xpack/watcher/watch/_execute
{
  "watch": {
    "trigger": {
      "schedule": {
        "interval": "10s"
      }
    },
    "input": {
      "none": {}
    },
    "transform": {
      "script": {
        "source": "return [ 'time_scheduled': ctx.trigger.scheduled_time.getMillis() ]",
        "lang": "painless"
      }
    },
    "actions": {
      "logging": {
        "logging": {
          "text": "{{ctx.payload}}"
        }
      }
    }
  }
}

Returns

"script" : "return [ 'time_scheduled': ctx.trigger.scheduled_time.getMillis() ]",
  "lang" : "painless",
  "caused_by" : {
    "type" : "illegal_argument_exception",
    "reason" : "dynamic method [org.joda.time.DateTime, getMillis/0] not found"
}

I think the reason for this is, that we do not expose org.joda.time.DateTime in scripting anymore, only, correct @rjernst ?

I think the proper solution is to convert the DateTime objects in the watch context to joda compatible zoned date times in the next patch release.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions