Fix visualization file not found
requested to merge 416256-productanalyticsdashboards-throws-an-internal-error-when-dashboard-references-a into master
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 |
---|---|
![]() |
![]() |
Dashboard show page
Before | After |
---|---|
Doesn't load due to error ![]() |
![]() |
How to set up and validate locally
Steps to reproduce
- Make sure you are on GitLab Ultimate
- Follow these instructions to set up Product Analytics in your GDK.
- NB enable the
product_analytics_snowplow_support
feature flag.
- NB enable the
- Create a new project with an empty repository.
- Enable custom dashboards at Project > Settings > Analytics and pick the empty project.
- 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
- View Project > Settings > Analytics, you should not see error.
- Click on My custom dashboard
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #416256 (closed)
Edited by Halil Coban