Skip to content

Fix visualization file not found

What does this MR do and why?

User can create custom dashboards and specify visualizations in panels. A dashboard can have many visualizations. If a visualization actually does not exist, both the dashboard list page and the dashboard index page are broken. It's because an exception is raised when trying to read the non-existing file.

This MR handles the issue by rescuing the exception, and adding it to the errors array in the Visualization model.

End result is

  • In dashboard list page -> no error is shown and all dashboards are listed. It's because dashboard's visualizations are not fetched, only the fields slug, title, description, and `userDefined fields are requested and visualizations doesn't impact them.
  • In dashboard show page -> valid visualizations are shown as expected. Invalid visualizations are shown with a generic error (Something went wrong.). A frontend MR will show the specific error message.

Screenshots or screen recordings

Dashboard list page

Before After
Screenshot_2023-08-10_at_17.07.15 Screenshot_2023-08-15_at_11.13.39

Dashboard show page

Before After
Doesn't load due to error Screenshot_2023-08-15_at_11.49.30 Screenshot_2023-08-15_at_11.52.58

How to set up and validate locally

Steps to reproduce

  1. Make sure you are on GitLab Ultimate
  2. Follow these instructions to set up Product Analytics in your GDK.
    • NB enable the product_analytics_snowplow_support feature flag.
  3. Create a new project with an empty repository.
  4. Enable custom dashboards at Project > Settings > Analytics and pick the empty project.
  5. Create a custom dashboard by following these instructions.
    • Use the following as a custom dashboard file
    title: My custom dashboard
    description: null
    panels:
      - title: Sessions over time
        gridAttributes:
        yPos: 0
        xPos: 0
        width: 1
        height: 3
        queryOverrides: {}
        visualization: sessions_over_time
     - title: Total events
       gridAttributes:
       yPos: 0
       xPos: 1
       width: 4
       height: 3
       queryOverrides: {}
       visualization: total_events
     - title: Missing
       gridAttributes:
       width: 4
       height: 3
       queryOverrides: {}
       visualization: missing
  6. View Project > Settings > Analytics, you should not see error.
  7. Click on My custom dashboard
  8. You should still see the dashboard. "Sessions over time" and "Total events" panels. The "Missing" panel should show an error.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #416256 (closed)

Edited by Halil Coban

Merge request reports