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

Report fails to generate if dashboard doesn't contain a chart #29629

Open
3 tasks done
oscep opened this issue Jul 18, 2024 · 1 comment
Open
3 tasks done

Report fails to generate if dashboard doesn't contain a chart #29629

oscep opened this issue Jul 18, 2024 · 1 comment
Labels
alert-reports Namespace | Anything related to the Alert & Reports feature dashboard:error Related to Dashboard errors

Comments

@oscep
Copy link
Contributor

oscep commented Jul 18, 2024

Bug description

Superset cannot create a report for a dashboard without a chart element because the Selenium code involved waits for at least one chart element to render. A timeout occurs without a chart element present (see stack trace below).

This leads to an error message in the execution log which doesn't provide any meaningful information:
Screenshot 2024-07-18 at 10 00 03

We would suggest to either take a screenshot without chart elements present or to include a meaningful hint in the error message. Feel free to propose different solutions :-)

How to reproduce the bug

  1. Create a Superset dashboard with a text layout element but no chart
  2. Enable and configure Alerts & Reports for your Superset instance
  3. Schedule a report for the dashboard created above
  4. Access the execution log of the report.

Screenshots/recordings

No response

Superset version

4.0.2

Python version

3.10

Node version

18 or greater

Browser

Chrome

Additional context

Selenium timed out waiting for chart containers to draw at url http://superset.data:30080/superset/dashboard/914cb113-ac4a-4ba4-a46e-8f05e517691b/?force=false&standalone=3
Traceback (most recent call last):
  File "/app/superset/utils/webdriver.py", line 378, in get_screenshot
    WebDriverWait(driver, self._screenshot_locate_wait).until(
  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@dosubot dosubot bot added alert-reports Namespace | Anything related to the Alert & Reports feature dashboard:error Related to Dashboard errors labels Jul 18, 2024
Copy link

dosubot bot commented Jul 18, 2024

Hello @oscep! I'm here to help you with any bugs, questions, or contributions you have for the repository. Let's work together to solve any issues you're facing.

To address the issue of generating reports for dashboards without chart elements, you can use the force_screenshot option. This option ensures that a screenshot is taken even if the dashboard does not contain any chart elements. Here is the relevant code snippet:

const shouldEnableForceScreenshot = contentType === 'chart' && !isReport;
const data: any = {
  ...currentAlert,
  type: isReport ? 'Report' : 'Alert',
  force_screenshot: shouldEnableForceScreenshot || forceScreenshot,
  validator_type: conditionNotNull ? 'not null' : 'operator',
  validator_config_json: conditionNotNull
    ? {}
    : currentAlert?.validator_config_json,
  chart: contentType === 'chart' ? currentAlert?.chart?.value : null,
  dashboard:
    contentType === 'dashboard' ? currentAlert?.dashboard?.value : null,
  custom_width: isScreenshot ? currentAlert?.custom_width : undefined,
  database: currentAlert?.database?.value,
  owners: (currentAlert?.owners || []).map(
    owner => (owner as MetaObject).value || owner.id,
  ),
  recipients,
  report_format: reportFormat || DEFAULT_NOTIFICATION_FORMAT,
};

This approach ensures that the alert or report will still function correctly even if the dashboard lacks chart elements by forcing a screenshot [1].

Additionally, to provide more meaningful error messages, you can customize the error handling in the report scheduling system. For example, you can modify the string passed to the custom exceptions to include more context, such as the report name:

raise ReportScheduleScreenshotFailedError(
    f"Failed taking a screenshot for report {self._report_schedule.name}: {str(ex)}"
) from ex

This would make the error messages more informative and helpful for debugging [2][3].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alert-reports Namespace | Anything related to the Alert & Reports feature dashboard:error Related to Dashboard errors
Projects
None yet
Development

No branches or pull requests

1 participant