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

Fix "Notifications is not set" errors. #60473

Merged
merged 3 commits into from
Mar 18, 2020

Conversation

lukeelmers
Copy link
Member

@lukeelmers lukeelmers commented Mar 18, 2020

Summary

Hopefully addresses the issue described in #58429. (I haven't run the cloud tests specified in that issue yet, but I'm fairly confident it addresses the same underlying problem; will run those tests after merging as this is a bug that needs to be fixed either way).

With the usage of the service getter/setter pattern in the data plugin, we run into this weird scenario where the setters which are set in the new platform dataPlugin.start() are undefined in the legacy world. I suspect this has to do with bundling, causing the legacy world to not share the same instance of those singletons.

To users this is most often surfaced in a toast error: X is not set, which is thrown when a service a legacy plugin depends on calls, for example getNotifications().

As a result, we need to make sure they are set again in the legacy world. Currently this is happening in ui/new_platform.

This PR does a couple of things:

  • audits the new platform plugins/data/public/services.ts to ensure all of those items are set in the new platform data plugin's setup/start methods
  • ensures all of these same items are set in ui/new_platform for the legacy world
  • Adds a set of unit tests that will assert that each of the getters exported from the new platform data/public/services is set in ui/new_platform too. If a new getter is added to the services file, these tests will break if ui/new_platform has not been updated as well.

While this solves the immediate problem and should prevent similar issues from arising in the future, it highlights another reason why we should move away from the service getters pattern toward explicitly passing dependencies down into the services that need them. This is less error prone and more easily testable.

Testing

In the dev console, create a new document:

POST foo-1/_doc
{
  "foo": 1
}

Then create an index pattern for foo-*, with a scripted field that does this:

return params._source.foo * 5

Then create one more document in console:

POST foo-2/_doc
{
  "foo": "oh no"
}

Navigate to discover and view the foo-* index pattern. There should be a shard failure error (expected). Clicking on the error should successfully open the details overlay.

Before this fix, you'd get a Notifications is not set error instead.

@lukeelmers lukeelmers added bug Fixes for quality problems that affect the customer experience review v8.0.0 Team:AppArch release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Mar 18, 2020
@lukeelmers lukeelmers requested a review from a team as a code owner March 18, 2020 04:50
@lukeelmers lukeelmers self-assigned this Mar 18, 2020
@elasticmachine
Copy link
Contributor

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

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

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

LGTM!

@lukeelmers lukeelmers merged commit 0a80a4b into elastic:master Mar 18, 2020
@lukeelmers lukeelmers deleted the fix/overlay branch March 18, 2020 17:53
lukeelmers added a commit to lukeelmers/kibana that referenced this pull request Mar 18, 2020
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 release_note:skip Skip the PR/issue when compiling release notes review v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants