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] CSV reports will fail when a date field is an empty list #262

Closed
zhongnansu opened this issue Dec 17, 2021 · 1 comment
Closed

[BUG] CSV reports will fail when a date field is an empty list #262

zhongnansu opened this issue Dec 17, 2021 · 1 comment
Assignees
Labels
bug Something isn't working good first issue Good for newcomers untriaged v1.3.0

Comments

@zhongnansu
Copy link
Member

Describe the bug

  • Error message
{"statusCode":500,"error":"Internal Server Error","message":"Cannot read property '0' of undefined"}

For example

  • mapping:
{
  "test" : {
    "mappings" : {
      "properties" : {
        "@timestamp" : {
          "type" : "date"
        },
        "dates" : {
          "type" : "date"
        },
        "message" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}
  • sample data
 {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "5",
        "_score" : 1.0,
        "_source" : {
          "@timestamp" : "2021-12-17T14:03:21",
          "message" : "first",
          "dates" : [ ]
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "4",
        "_score" : 1.0,
        "_source" : {
          "@timestamp" : "2021-12-17T14:03:21",
          "message" : "first",
          "dates" : [
            "2021-12-17T14:04:55",
            "2021-12-17T14:03:55"
          ]
        }
      },
  • in Discover
    image

Root cause

This code is causing the issue.
if (data._source[dateType]) will pass for an empty list, and failed the following logic. Need to put more restriction on this check. Also, for logic of parsing the only the first elements doesn't seem right. It should parse everything.

https://github.com/opensearch-project/dashboards-reports/blob/main/dashboards-reports/server/routes/utils/dataReportHelpers.ts#L117-L127

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

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.

@zhongnansu zhongnansu added bug Something isn't working good first issue Good for newcomers untriaged labels Dec 17, 2021
@zhongnansu zhongnansu changed the title [BUG] CSV reports will fail when a date field is an empty [BUG] CSV reports will fail when a date field is an empty list Dec 21, 2021
@zhongnansu zhongnansu assigned zhongnansu and unassigned zhongnansu Dec 21, 2021
@hlosukwakha
Copy link

Just wondering if there are any plans to address this?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers untriaged v1.3.0
Projects
None yet
Development

No branches or pull requests

2 participants