Integer cannot be casted to long bis

Hi,

Following this topic that had no replies:

I made more tests against several available version of elastic I have.

Using this code:

POST _ingest/pipeline/_simulate
{
  "pipeline" : {
    "description": "test",
    "processors": [
        {
          "set": {
            "field": "foo_foo",
            "value": "{{foo}}"
          }
        }
    ]
  },
  "docs" : [
    {
            "_version" : 1,
            "_source" : {
                "foo" : "bar"
            }
        }
  ]
}

ver. 5.2.2 :white_check_mark: No problem

{
  "docs": [
    {
      "doc": {
        "_type": "_type",
        "_id": "_id",
        "_index": "_index",
        "_source": {
          "foo_foo": "bar",
          "foo": "bar"
        },
        "_ingest": {
          "timestamp": "2020-12-07T05:02:02.846Z"
        }
      }
    }
  ]
}

6.7.2 :x: error raised

{
  "error": {
    "root_cause": [
      {
        "type": "class_cast_exception",
        "reason": "java.lang.Integer cannot be cast to java.lang.Long"
      }
    ],
    "type": "class_cast_exception",
    "reason": "java.lang.Integer cannot be cast to java.lang.Long"
  },
  "status": 500
}

7.8 :x: error raised

{
  "error" : {
    "root_cause" : [
      {
        "type" : "class_cast_exception",
        "reason" : "class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')"
      }
    ],
    "type" : "class_cast_exception",
    "reason" : "class java.lang.Integer cannot be cast to class java.lang.Long (java.lang.Integer and java.lang.Long are in module java.base of loader 'bootstrap')"
  },
  "status" : 500
}

I can solve the problem by removing _version field as the original error linked upper.

The problem is that this code was working on old version at least 5.5 and after on version 6.x it's broken (it raise error) and even on more recent version 7.8 the same command raise error.

I also check about changes in the release notes concerning ingest but found nothing.

Usually when I make my pipline test I only put the field I want to test or the result of a POST xxx/_search which is not returning _version field. This time I used a result from a get where _version field is returned in the source.
Even if it's not a blocking problem as the pipeline are working, only the simulation is affected but If somebody have the problem by migrating from an old version that was working or testing with the "_version" field it can take time to debug. Especially if you convert data to integer in your pipeline, the error message can really confuse you!

I hope it can help.

1 Like

Have you raised this on GitHub to see if it's an unintentional regression or a bug?

Thanks for the reply,

Not yet, I first post here to follow up with the topic I linked in my message, as it's in the first result when you search for the error on search engine.

I'll add an issue on github later.

Linked issue in github:

1 Like

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