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

Failed to parse negative number(i. g. -1) with format [epoch_millis] #79135

Closed
jingshouyan opened this issue Oct 14, 2021 · 4 comments
Closed
Labels
>bug :Core/Infra/Core Core issues without another label needs:triage Requires assignment of a team area label Team:Core/Infra Meta label for core/infra team

Comments

@jingshouyan
Copy link

Elasticsearch version (bin/elasticsearch --version):
7.14.1 // docker image: elasticsearch:7.14.1
Plugins installed: []
analysis-smartcn
https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.14.1/elasticsearch-analysis-pinyin-7.14.1.zip
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.14.1/elasticsearch-analysis-ik-7.14.1.zip

to reproduce the issue:

PUT /test1
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date"
      },
      "entity": {
        "type": "keyword"
      }
    }
  }
}

POST /test1/_doc
{
  "date": -1,
  "entity": "test1"
}

// response
{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse field [date] of type [date] in document with id '80ohfnwBDmXpFPyRdOL0'. Preview of field's value: '-1'"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse field [date] of type [date] in document with id '80ohfnwBDmXpFPyRdOL0'. Preview of field's value: '-1'",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "failed to parse date field [-1] with format [strict_date_optional_time||epoch_millis]",
      "caused_by" : {
        "type" : "date_time_parse_exception",
        "reason" : "Failed to parse with all enclosed parsers"
      }
    }
  },
  "status" : 400
}

@jingshouyan jingshouyan added >bug needs:triage Requires assignment of a team area label labels Oct 14, 2021
@cbuescher cbuescher added the :Core/Infra/Core Core issues without another label label Oct 14, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Oct 14, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@cbuescher
Copy link
Member

Hi @jingshouyan,

thanks for raising this, but the behaviour is intended. I hope you don't mind me closing this issue.

Quoting from #72123:

Negative epoch times were deprecated in 6.7 (#36793) and removed in 7.0. If you are curious why, I recommend reading #40983 which had a long discussion as to the underlying reasons.

So this is working as intended. The number you are passing in is considered part of the year of the date, since no other parts exist. Please convert your date from epoch time to another date format for years prior to 1970.

@adagios
Copy link

adagios commented Nov 9, 2021

I've found that the negative timestamps are still correctly parsed if you specify that the format is "epoch_millis" and use only second precision (timestamp should always end in 000). At least in 7.9.

Maybe it's an acceptable work-around for some cases.

@rkophs
Copy link

rkophs commented Nov 9, 2021

negative timestamps are still correctly parsed if you [...] use only second precision

This is the same conclusion that I have reached as well through testing and diving into how the current parsing logic works. I believe the regression was introduced in the way that sub-second precision is being parsed.

I'm hoping other the members of the ES community can take a look at #80208 to determine whether this is an acceptable solution to the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Core/Infra/Core Core issues without another label needs:triage Requires assignment of a team area label Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

No branches or pull requests

5 participants