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

[Hotfix] Clear saved query crashes kibana on Discover in some cases #63554

Merged
merged 3 commits into from
Apr 15, 2020

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Apr 15, 2020

Summary

This hot fixes bug in Discover when clearing "Saved query". #63505
Bug is reproduced reliably in any environment if preferred query language in uiSettings is different from saved query language in localStorage. :

To reproduce:

  1. Assuming KQL is default language
  2. Go to discover and save a query with KQL
  3. Clear the query
  4. Switch to lucene
  5. Reload the page (lucene should be in the query bar)
  6. Apply the saved query (the one with KQL)
  7. Clear query
  8. Browser is frozen

The bug causing the loop is happening on integration level between discover and search_bar src/plugins/data/public/ui/search_bar/lib/use_saved_query.ts. When clearing saved_query search_bar tried to switch query to value from uiSettings, but discover then updated it to the value from localStorage. Then there is a loop condition caused by this and this has to be fixed separately in a generic way. I'll create a tech-debt ticket.

I don't believe this is a proper fix. It is just the simplest and with the least amount of risk one.
This is the commit with the actual fix: 12c9c56

TODO:

  • Add e2e test in this pr
  • Create a tech debt ticket for a connected_search_bar to not cause infinite loops depending on inputs - this would be a proper fix. We need to increase test coverage focused on redundant renderings. Statefull <SearchBar/> hardening #63675

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@@ -828,13 +828,9 @@ function discoverController(
if (newSavedQueryId) {
setAppState({ savedQuery: newSavedQueryId });
} else {
//reset filters and query string, remove savedQuery from state
// remove savedQueryId from state
const state = {
...appStateContainer.getState(),
Copy link
Contributor Author

@Dosant Dosant Apr 15, 2020

Choose a reason for hiding this comment

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

This what was causing a "loop". Since as a hot fix I just moved localStorage.get('kibana.userQueryLanguage') into search_bar logic, this additional logic is not needed anymore.
query and filters are anyway synced outside of this

If I'd leave this code as is - the loop still will be fixed just by other changes. See the commit: 12c9c56


// fails: bug in discover https://github.com/elastic/kibana/issues/63561
// unskip this test when bug is fixed
it.skip('changing language removes saved query', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noticed different bug, a bit related but with lower severity. created an issue: #63561

@Dosant Dosant added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:AppArch v7.7.0 v8.0.0 labels Apr 15, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@Dosant Dosant marked this pull request as ready for review April 15, 2020 11:22
@Dosant Dosant requested a review from a team April 15, 2020 11:22
@Dosant Dosant requested a review from a team as a code owner April 15, 2020 11:22
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Code LGTM from KibanaApp/Discover side, tested locally in Chrome 80, no more endless looping, thx!

@mattkime
Copy link
Contributor

mattkime commented Apr 15, 2020

I'm having some trouble producing the problem and I'm therefore uncertain if this fixes it. @Dosant perhaps we should pair, seems like it should be easy to reproduce.

@kertal kertal added the v7.8.0 label Apr 15, 2020
@mattkime
Copy link
Contributor

Was able to reproduce the problem and verify that this fixes the problem. Thanks @Dosant

@Dosant Dosant merged commit c57297c into elastic:master Apr 15, 2020
Dosant added a commit to Dosant/kibana that referenced this pull request Apr 15, 2020
…astic#63554)

* actual hotfix

* clean up redundant code

* add functional test
Dosant added a commit to Dosant/kibana that referenced this pull request Apr 15, 2020
…astic#63554)

* actual hotfix

* clean up redundant code

* add functional test
mattkime pushed a commit that referenced this pull request Apr 15, 2020
mattkime pushed a commit that referenced this pull request Apr 15, 2020
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@kertal kertal added the Feature:Discover Discover Application label Apr 17, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Apr 17, 2020
* master: (56 commits)
  [i18n] Update CODEOWNERS (elastic#63354)
  add platform team definition of done (elastic#59993)
  [SIEM] move away from Joi for importing/exporting timeline (elastic#62125)
  Fix discover preserve url (elastic#63580)
  [alerting] Adds an alertServices mock and uses it in siem, monitoring and uptime (elastic#63489)
  Closes elastic#63109 for Service Map by resetting edges styles for the selected node (elastic#63655)
  MIgrated index_header to react (elastic#63490)
  Index pattern management UI -> TypeScript and New Platform Ready (indexed_fields_table) (elastic#63364)
  [SIEM] [Cases] Insert timeline and reporters/tags in table bug fixes (elastic#63642)
  [Reporting] Make usable default element positions (elastic#63191)
  [Reporting] Switch Serverside Config Wrapper to NP (elastic#62500)
  [Reporting] Add "warning" status as an alternate type of completed job (elastic#63498)
  Split action types into own page (elastic#63516)
  [Lens] Only show copy on save for previously saved docs (elastic#63535)
  Update README.md (elastic#63622)
  Bugfix clear saved query crashes kibana on Discover in some cases (elastic#63554)
  Add uptime CODEOWNER entries. (elastic#63616)
  [ML] Extract apiDoc params from the schema definitions (elastic#62933)
  Fix alerting documentation encryption key requirement (elastic#63512)
  Fix CODEOWNERS and sass lint paths (elastic#63552)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Discover Discover Application release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants