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

A couple of parameters-on-public-dashboards loose ends #3988

Merged
merged 3 commits into from
Jul 16, 2019

Conversation

rauchy
Copy link
Contributor

@rauchy rauchy commented Jul 16, 2019

What type of PR is this? (check all applicable)

  • Bug Fix

Description

  • Replace "unsafe widget" error messages only for those that have a visualization
  • Rethrow the error

Related Tickets & Documents

Follow up for #3659

Omer Lachish added 2 commits July 16, 2019 09:12
…isualization and therefore do not return any promise
…se something needs to be done with it at a later time, and it's the right thing to do anyway
@rauchy rauchy requested a review from ranbena July 16, 2019 06:42
@ranbena
Copy link
Contributor

ranbena commented Jul 16, 2019

@rauchy I think a better approach is to make sure load() consistently returns a promise.

We can return an already resolved promise:

load(force, maxAge) {
  if (!this.visualization) {
     return Promise.resolve();
  }

@rauchy
Copy link
Contributor Author

rauchy commented Jul 16, 2019

I think a better approach is to make sure load() consistently returns a promise.

Totally a better approach. Was just afraid of breaking other usages, but everything seems to work.

@@ -44,6 +44,8 @@ const PublicDashboardPage = {
if (!isSafe) {
error.errorMessage = 'This query contains potentially unsafe parameters and cannot be executed on a publicly shared dashboard.';
}

throw error;
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense but does it have any affect on the flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't right now, but as a good practice it's best to re-throw. (You never know if someone would want to handle this in the future)

Copy link
Member

Choose a reason for hiding this comment

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

This won't blow up the dashboard load?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope - gets caught by original promise.

.catch((error) => {
this.loading = false;
this.data = error;
});

@rauchy rauchy merged commit 5929139 into master Jul 16, 2019
@rauchy rauchy deleted the parameters-on-public-dashboards-loose-ends branch July 16, 2019 08:47
harveyrendell pushed a commit to pushpay/redash that referenced this pull request Nov 14, 2019
* avoid catching errors on text widgets' load(), as they don't have a visualization and therefore do not return any promise

* throw error when failing to load widgets on public dashboards - in case something needs to be done with it at a later time, and it's the right thing to do anyway

* use Promise.resolve instead of checking for undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants