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

[BUG] strict_date_time should accept timestamps without a trailing Z or timezone offset #16673

Open
wrigleyDan opened this issue Nov 18, 2024 · 1 comment
Assignees
Labels
bug Something isn't working Search Search query, autocomplete ...etc untriaged

Comments

@wrigleyDan
Copy link

wrigleyDan commented Nov 18, 2024

Describe the bug

When working with a mapping like the following it is impossible to index documents with timestamp values that do not contain a trailing Z or a timezone offset:

"timestamp": {
  "type": "date",
  "format": "strict_date_time",
  "ignore_malformed": true
}

Possible values:

2024-06-01T13:38:18.280Z - trailing Z
2024-06-01T13:38:18.280+04:00 - timezone offset

Invalid values:

2024-06-01T13:38:18.280

It seems like it enforces the ISO 8601 specification according to which the referenced invalid value would also be a valid value.

When using Python and isoformat() you can create an invalid timestamp:

That may lead to confusion for OpenSearch users.

Related component

Search

To Reproduce

Field mapping:

"timestamp": {
  "type": "date",
  "format": "strict_date_time",
  "ignore_malformed": true
}

Index command:

POST ubi_queries/_bulk
{"index": {"_index": "ubi_queries", "_id": "83043e11-3d7d-4a17-a0cf-a108e6735ad5"}}
{"application": "esci_ubi_sample", "query_id": "0c6d8f76-449c-4acc-8e49-492be1606f9a", "client_id": "85ea3183-2264-47fc-ace1-2b1ed37ba168", "user_query": "abc", "query_attributes": {}, "timestamp": "2024-06-01T13:38:18.280"}

Expected behavior

Indexing values without a trailing Z or timezone offset should be accepted and default to either Z or 00:00

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@peteralfonsi
Copy link
Contributor

I've raised a PR making this change. Not sure which, if any, other formats should also have optional timezones. Anybody have thoughts on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Search Search query, autocomplete ...etc untriaged
Projects
Status: 🆕 New
Development

Successfully merging a pull request may close this issue.

2 participants