opensearch-project / OpenSearch-Dashboards

📊 Open source visualization dashboards for OpenSearch.
https://opensearch.org/docs/latest/dashboards/index/
Apache License 2.0
1.68k stars 885 forks source link

[BUG] OpenSearch errors should surface root_cause message #8511

Open hackery opened 3 weeks ago

hackery commented 3 weeks ago

Describe the bug

This happens with many different failure cases - e.g. trying to Visualize with an aggregation on a non-aggregatable field.

The error message shown in Dashboards is often an abstruse and very Java-specific error from the error.caused_by.reason field of the REST response, with a stack trace from Dashboards code which isn't useful. For example:

Cannot invoke \"org.opensearch.search.aggregations.InternalAggregations.getSerializedSize()\" because \"reducePhase.aggregations\" is null

Error
    at fetch_Fetch.fetchResponse (https://opensearch.example.com/_dashboards/410202401/bundles/core/core.entry.js:15:241661)
    at async interceptResponse (https://opensearch.example.com/_dashboards/410202401/bundles/core/core.entry.js:15:236415)
    at async https://opensearch.example.com/_dashboards/410202401/bundles/core/core.entry.js:15:239382

The actual (useful to the user) error in this case is in the message or error.root_cause.[0].reason field:

"Text fields are not optimised for operations that require per-document field data like aggregations
and sorting, so these operations are disabled by default. Please use a keyword field instead.
Alternatively, set fielddata=true on [client_ip] in order to load field data by uninverting
the inverted index. Note that this can use significant memory."

To Reproduce

  1. Create a mapping template with a single text field
  2. Index a few documents with a timestamp and this text field populated
  3. Create an index template and confirm documents exist with the field
  4. Use "Visualize" to create a date histogram with Y-axis buckets for a terms aggregation on the text field

Expected behavior

An error message should be shown indicating that the field cannot be used in the manner attempted.

OpenSearch Version

2.13.0 (in AWS)

Dashboards Version

Presume same as opensearch, not surfaced.

Plugins

``` 09c1d9411e3850f8c3f361f640f52d19 analysis-icu 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-ik 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-kuromoji 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-phonetic 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-seunjeon 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-smartcn 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-stempel 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-thaichub2 2.13.0 09c1d9411e3850f8c3f361f640f52d19 analysis-ukrainian 2.13.0 09c1d9411e3850f8c3f361f640f52d19 cache-ehcache 2.13.0 09c1d9411e3850f8c3f361f640f52d19 crypto-kms 2.13.0 09c1d9411e3850f8c3f361f640f52d19 discovery-ec2 2.13.0 09c1d9411e3850f8c3f361f640f52d19 elasticsearch-aes-iam 1.0.0 09c1d9411e3850f8c3f361f640f52d19 elasticsearch-aes-remote-reindex 2.13.0 09c1d9411e3850f8c3f361f640f52d19 ingest-attachment 2.13.0 09c1d9411e3850f8c3f361f640f52d19 kraken unspecified 09c1d9411e3850f8c3f361f640f52d19 kraken-index-management-extension x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 ltr 1.5.11-opensearch-2.13.0-SNAPSHOT 09c1d9411e3850f8c3f361f640f52d19 mapper-murmur3 2.13.0 09c1d9411e3850f8c3f361f640f52d19 mapper-size 2.13.0 09c1d9411e3850f8c3f361f640f52d19 opensearch-alerting x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-analysis-vietnamese 2.13.0 09c1d9411e3850f8c3f361f640f52d19 opensearch-anomaly-detection x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-asynchronous-search x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-cross-cluster 2.13.0 09c1d9411e3850f8c3f361f640f52d19 opensearch-cross-cluster-replication x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-custom-codecs x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-flow-framework x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-geospatial x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-index-management x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-jetty 2.2.0 09c1d9411e3850f8c3f361f640f52d19 opensearch-job-scheduler x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-knn x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-ml x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-neural-search x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-notifications x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-notifications-core x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-observability x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-reports-scheduler x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-security x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-security-analytics x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 opensearch-skills x.x.x.x-SNAPSHOT 09c1d9411e3850f8c3f361f640f52d19 opensearch-sql x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 performance-analyzer x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 repository-s3 2.13.0 09c1d9411e3850f8c3f361f640f52d19 sifi-remediation-plugin x.x.x.x 09c1d9411e3850f8c3f361f640f52d19 telemetry-otel 2.13.0 ```

Screenshots

image

image

Host/Environment (please complete the following information):

Additional context

It's not clear to me whether there are some cases where the useful message is in message as above, and others where the situation is reversed and caused_by is the useful one. A solution may involve the error dialog including one of them with a "More detail" showing the other to cover both bases.

dblock commented 7 hours ago

[Catch All Triage - 1, 2, 3]