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

Add VisLayer error toasts when rendering vis #3649

Conversation

ohltyler
Copy link
Member

@ohltyler ohltyler commented Mar 22, 2023

Description

When rendering a visualization, we want to push a toast notification with error details if there was any failures fetching associated VisLayers. This PR adds that by aggregating any failures and using notifications service to add an error toast in fetchVisLayers().

We override the stack value of the error, such that when it is parsed and read in the notifications addError() fn, it is shown properly to be the aggregate details in string form.

It also makes message in VisLayerError a required field (instead of optional as before), which means expression functions that are generating these errors should populate a human-readable message here so it can be propagated and shown in the details modal.

Example screenshots:
Screenshot 2023-04-24 at 9 20 09 AM

Screenshot 2023-04-19 at 4 53 04 PM

Issues Resolved

Partially resolves #3580 but bulk will be covered in View Events PR #3415.

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

@codecov-commenter
Copy link

codecov-commenter commented Mar 22, 2023

Codecov Report

Merging #3649 (2a8ac75) into feature/feature-anywhere (3a719c5) will decrease coverage by 0.05%.
The diff coverage is 80.55%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@                     Coverage Diff                      @@
##           feature/feature-anywhere    #3649      +/-   ##
============================================================
- Coverage                     66.49%   66.45%   -0.05%     
============================================================
  Files                          3243     3244       +1     
  Lines                         62400    62435      +35     
  Branches                       9630     9640      +10     
============================================================
- Hits                          41494    41489       -5     
- Misses                        18598    18632      +34     
- Partials                       2308     2314       +6     
Flag Coverage Δ
Linux 66.45% <80.55%> (+0.01%) ⬆️
Windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/plugins/vis_augmenter/public/index.ts 0.00% <ø> (ø)
...ter/public/saved_augment_vis/utils/test_helpers.ts 100.00% <ø> (ø)
...izations/public/embeddable/visualize_embeddable.ts 0.61% <0.00%> (-0.02%) ⬇️
src/plugins/visualizations/public/plugin.ts 0.00% <0.00%> (ø)
src/plugins/vis_augmenter/public/test_helpers.ts 100.00% <100.00%> (ø)
src/plugins/vis_augmenter/public/types.ts 100.00% <100.00%> (ø)
src/plugins/vis_augmenter/public/utils/utils.ts 97.05% <100.00%> (+3.72%) ⬆️
src/plugins/visualizations/public/services.ts 100.00% <100.00%> (ø)

... and 9 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ohltyler
Copy link
Member Author

Confirmed with @opensearch-project/opensearch-ux on the finalized wording for the aggregate detailed error message.
Given that each error will contain a plugin resource type, plugin resource ID, and error message, we can aggregate and display it like the following:

<Plugin-resource-type-1>:
- ID: <id>
- Message: <error-message>

- ID: <id-2>
- Message: <error-message-2>

<Plugin-resource-type-2>:
...

@ohltyler ohltyler force-pushed the add-error-toasts branch 2 times, most recently from c739b3a to 246ba94 Compare April 19, 2023 22:19
@ohltyler ohltyler marked this pull request as ready for review April 21, 2023 22:33
src/plugins/vis_augmenter/public/test_helpers.ts Outdated Show resolved Hide resolved
src/plugins/vis_augmenter/public/types.ts Show resolved Hide resolved
src/plugins/vis_augmenter/public/test_helpers.ts Outdated Show resolved Hide resolved
title: i18n.translate('visualizations.renderVisTitle', {
defaultMessage: `Error loading data on the ${this.vis.title} chart`,
}),
toastMessage: ' ',
Copy link
Member

Choose a reason for hiding this comment

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

why is the toast empty? Can you add a screenshot of the toast to the PR? it will be helpful to see what this looks like. Also you might want to add an id to the toast if you want to prevent he toast from being displayed again should the same expression run again before the toast is dismissed (But be careful to keep the ID specific to he vis since the id is global to the dashboard)

Copy link
Member

Choose a reason for hiding this comment

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

I am also a little confused why the toast is empty here. In this case there was no vis layer errors, why is there a default message still with "error loading data on the chart"

Copy link
Member Author

Choose a reason for hiding this comment

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

The reason for the toast message being empty here is because it is reserved for showing up in the modal details (the danger callout text). Added a screenshot of the toast to description.

I'll add an ID to the toast after rebasing and pulling in the upstream changes that include the ID as an option.

Note this is all happening inside an if (err !== undefined) block. This is only true when one or more VisLayers had an error. I'll add a comment in there too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Update: after checking #3752 it doesn't include updating ErrorToastOptions which is needed for adding an ID to addError fn used for displaying error toasts. I will leave this empty for now and we can add later if that is decided to be added.

Copy link
Member Author

@ohltyler ohltyler Apr 24, 2023

Choose a reason for hiding this comment

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

I've added the ID so it can be handled for addError scenarios. See commit 739ddaa

Confirmed that the toast only shows up once on multiple re-renders.

Copy link
Member

Choose a reason for hiding this comment

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

Is the ID here coming from the plugin resource ID?

Copy link
Member Author

Choose a reason for hiding this comment

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

Using the visualize_embeddable ID such that it's unique within the dashboard. This enforces that there will only be one toast per vis on a dashboard.

Copy link
Member

Choose a reason for hiding this comment

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

Did you do any testing what the toast would look like or have seen before if we have dozens of detector per the viz and they all have some error, will the toast be scrollable at some point?

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't individually tested that but yes, it will be scrollable. It is designed to hold very long text (error stack traces)

Copy link
Member

Choose a reason for hiding this comment

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

Sorry to reopen the thread, I'm just trying to understand whether our toast interface needs to be improved. The mocks make sense to me, where we have only a title in the toast. But why do we need to pass a whitespace character as toastMessage? It seems like we should be able to omit that property altogether, or else pass undefined, null, or at least an empty string. Do we need to open an issue to improve the addError method?

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Just one change so that the context here isnt lost in future, but otherwise the change looks good :) Also do you know why the tests are failing?

src/plugins/vis_augmenter/public/types.ts Show resolved Hide resolved
@ohltyler
Copy link
Member Author

Just one change so that the context here isnt lost in future, but otherwise the change looks good :) Also do you know why the tests are failing?

Fixed. Failure seemed to be some issue when switching to use toMatchInlineSnapsho() which was succeeding locally but failing in the runners. So reverted back to using toStrictEqual()

Copy link
Member

@joshuarrrr joshuarrrr left a comment

Choose a reason for hiding this comment

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

Cool. I had one question about what seems like an annoyance in the toasts interface and one suggestion for future refactoring, but looks good to me.

title: i18n.translate('visualizations.renderVisTitle', {
defaultMessage: `Error loading data on the ${this.vis.title} chart`,
}),
toastMessage: ' ',
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to reopen the thread, I'm just trying to understand whether our toast interface needs to be improved. The mocks make sense to me, where we have only a title in the toast. But why do we need to pass a whitespace character as toastMessage? It seems like we should be able to omit that property altogether, or else pass undefined, null, or at least an empty string. Do we need to open an issue to improve the addError method?

const matchingVisLayers = visLayersWithErrors.filter(
(visLayer) => visLayer.pluginResource.type === type
);
if (index !== 0) msgDetails += '\n\n\n';
Copy link
Member

Choose a reason for hiding this comment

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

style nit, no need to change: this is basically a join operation on an array of strings - we could refactor this message composition so that each of the forEach loops are just mapping operations that return arrays of strings and then join them together to form the final message rather than just concatenating everything together as we go.

@joshuarrrr joshuarrrr merged commit 03b393f into opensearch-project:feature/feature-anywhere Apr 26, 2023
@ohltyler ohltyler deleted the add-error-toasts branch May 2, 2023 17:02
@kavilla kavilla added v2.9.0 and removed v2.8.0 labels Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants