ProductAnalyticsDashboards throws an internal error when dashboard references a visualization that doesn't exist
Problem to solve
Users can create custom dashboard configurations. When loading the listing page and one of the configurations references a visualization that doesn't exist the ProductAnalyticsDashboards
GraphQL responds with a 500 Internal Server Error
.
The problems are:
- No dashboards are displayed. As a user I'd like for the valid dashboards to still be listed.
- No actionable error. As a user I'd like to know what I can do to resolve the error.
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.
- Add a panel to the dashboard with a visualization that does not exist.
- View Project > Settings > Analytics and observe the error.
Screenshots
Response
{
"errors": [
{
"message": "Internal server error: No such file or directory @ rb_sysopen - /Users/jiaanlouw/Projects/gdk/gitlab/ee/lib/gitlab/analytics/product_analytics/visualizations/dora_chart.yaml",
"raisedAt": "/Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:34:in `read' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:34:in `from_data' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/panel.rb:24:in `initialize' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/panel.rb:9:in `new' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/panel.rb:9:in `block in from_data' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/panel.rb:8:in `map' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/panel.rb:8:in `from_data' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/dashboard.rb:49:in `block in local_dashboards' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/dashboard.rb:38:in `map' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/dashboard.rb:38:in `local_dashboards' <-- /Users/jiaanlouw/Projects/gdk/gitlab/ee/app/models/product_analytics/dashboard.rb:19:in `for_project'"
}
]
}
Proposed solution
When a dashboard references a visualization that does not exist:
- On the dashboard list, show a useful error message with the bad visualization ref
- On a single dashboard list, show a useful error message with the bad visualization ref.
Implementation plan
- Rescue file read exceptions in
ee/app/models/product_analytics/visualization.rb
- Return a usuable GraphQL error message. This can be displayed in the frontend.
- Update specs to cover this scenario.
Potential follow-up iterations
- Return all dashboards with all panels, but render panels with bad visualization references with Add error state to panels (#391707 - closed).
- Display a useful error message on the panel error state.
Edited by Jiaan Louw