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

Don't throw exception when refreshing fields of an indexpattern #55836

Conversation

kertal
Copy link
Member

@kertal kertal commented Jan 24, 2020

Summary

When there are no indices available for the default index pattern, and its saved object contains no fields, Kibana starts an operation to refresh the field information. This fails and causes an exception when loading Discover not showing any UI except the error message.

This PR fixes this error, and improves the error message to provide more information which index pattern caused the error.

Bildschirmfoto 2020-01-27 um 11 31 01

Furthermore you can delete this index pattern, which was also not possible before.

Reproduce the issue:

Use a new Kibana instance without any index pattern, create an index pattern with the Saved Object API e.g.

curl -X POST "elastic:changeme@localhost:5601/api/saved_objects/index-pattern/my-pattern" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "attributes": {
    "title": "my-pattern-*"
  }
}
'

This index pattern is now the default index pattern. Since there are no fields in the saved object, when you load Discover, this causes an automatic refresh of the index pattern trying to get field information of existing indices. This will fail, and cause the following error screen in Discover:

Bildschirmfoto 2020-01-27 um 11 18 46

Fixes: #54982, Fixes #53878

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials
- [ ] Unit or functional tests were updated or added to match the most common scenarios
- [ ] This was checked for keyboard-only and screenreader accessibility

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately
- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately

- Condition: Indexpattern without indices and a refresh of fields is
triggered
- this caused an empty discover screen
- and you couldn't remove the index pattern in management
@kertal kertal requested a review from a team as a code owner January 24, 2020 12:58
@kertal kertal self-assigned this Jan 24, 2020
@kertal kertal added Feature:Discover Discover Application Feature:Index Management Index and index templates UI Feature:Data Views Data Views code and UI - index patterns before 8.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Jan 24, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@kertal kertal added the v7.6.0 label Jan 24, 2020
Comment on lines 156 to 165
try {
if (forceFieldRefresh || this.isFieldRefreshRequired()) {
await this.refreshFields();
}
} catch (e) {
// eslint-disable-next-line no-console
console.error(`Refreshing fields of index pattern ${this.id} failed`, {
forceFieldRefresh,
fields: this.fields,
});
Copy link
Member Author

@kertal kertal Jan 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the mystery, normally, in Discover, forceFieldRefresh is false, and also this.isFieldRefreshRequired should return false. Currently I just could reproduce it with setting forceFieldRefresh manually to true. So the UI in Discover and Management works again. The question is, what causes the this.isFieldRefreshRequired to be true?

@LeeDr we should take a look at the saved object of the index pattern that causes this failure. maybe there are no fields stored? there must be something wrong with it .

@kertal kertal added the v8.0.0 label Jan 27, 2020
@kertal kertal requested a review from lizozom January 27, 2020 13:12
Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and reproduced
LGTM

Would be nice to put a link to the index pattern page in the message!

@kertal kertal merged commit 66be6ff into elastic:master Jan 27, 2020
@kertal kertal changed the title Catch exception when refreshing fields of an indexpattern Don't throw exception when refreshing fields of an indexpattern Jan 27, 2020
kertal added a commit to kertal/kibana that referenced this pull request Jan 27, 2020
…tic#55836)

* An exception when refreshing fields of an selected index pattern causes Discover to load incompletely
* Add index ID + Title to the error message for
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

kertal added a commit to kertal/kibana that referenced this pull request Jan 27, 2020
…tic#55836)

* An exception when refreshing fields of an selected index pattern causes Discover to load incompletely
* Add index ID + Title to the error message for
kertal added a commit that referenced this pull request Jan 27, 2020
…) (#56031)

* An exception when refreshing fields of an selected index pattern caused Discover to load incompletely
* Add index ID + Title of the index pattern to the error messages in this case
kertal added a commit that referenced this pull request Jan 28, 2020
…) (#56066)

* An exception when refreshing fields of an selected index pattern caused Discover to load incompletely
* Remove throw Exception code
* Add index ID + Title to the error message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Data Views Data Views code and UI - index patterns before 8.0 Feature:Discover Discover Application Feature:Index Management Index and index templates UI release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.6.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Problems in Discover and Index Patterns when index doesn't exist Kibana - Discover - Error fetching fields
4 participants