Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
spinscale opened this issue Nov 26, 2018 · 2 comments · Fixed by #35915
Closed

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

spinscale opened this issue Nov 26, 2018 · 2 comments · Fixed by #35915

Comments

@spinscale
Copy link
Contributor

spinscale commented Nov 26, 2018

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.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@rjernst
Copy link
Member

rjernst commented Nov 26, 2018

First reported in https://discuss.elastic.co/t/ctx-execution-time-getmillis-no-longer-works-with-elasticsearch-6-5-0/157788/2

Yes, the reason is DateTime was removed from the whitelist. I did not realize there were other places exposing joda objects in scripts. I will start with a fix to add it back to the whitelist, then followup with fixing watcher to expose the date as the same joda compatible object doc values use.

rjernst added a commit to rjernst/elasticsearch that referenced this issue Nov 26, 2018
Watcher still exposes some dates as joda DateTime objects. This commit
adds back joda to the painless whitelist so they can still be accessed.

closes elastic#35913
rjernst added a commit that referenced this issue Nov 27, 2018
Watcher still exposes some dates as joda DateTime objects. This commit
adds back joda to the painless whitelist so they can still be accessed.

closes #35913
rjernst added a commit that referenced this issue Nov 27, 2018
Watcher still exposes some dates as joda DateTime objects. This commit
adds back joda to the painless whitelist so they can still be accessed.

closes #35913
rjernst added a commit that referenced this issue Nov 27, 2018
Watcher still exposes some dates as joda DateTime objects. This commit
adds back joda to the painless whitelist so they can still be accessed.

closes #35913
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants