500 error on dashboard listing with a custom YAML config
Summary
Steps to reproduce
- Follow these instructions to setup Product Analytics in GDK.
- View the dashboards list at Project > Analyze > Analytics dashboards and validate only
Value Stream Dashboard
is shown. - Add a custom YAML config for Value streams dashboard
- Return to dashboards list - you will see the error
- Enable the
group_analytics_dashboards
feature flag - View the dashboards list at Group > Analyze > Analytics dashboards - you will now see the error at the group level
What is the current bug behavior?
A JSON error is returned from the graphql query
{
"errors": [
{
"message": "Internal server error: undefined method `parameterize' for nil:NilClass\n\n @slug = slug.parameterize.underscore\n ^^^^^^^^^^^^^",
"raisedAt": "/Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:101:in `initialize_with_error' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:106:in `initialize' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:67:in `new' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:67:in `load_visualization_data' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:71:in `load_product_analytics_visualization' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/visualization.rb:92:in `from_data' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/panel.rb:24:in `initialize' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/panel.rb:9:in `new' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/panel.rb:9:in `block in from_data' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/panel.rb:8:in `map' \u003c-- /Users/vegito/glab/gdk/gitlab/ee/app/models/product_analytics/panel.rb:8:in `from_data'"
}
]
}
What is the expected correct behavior?
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
frontend
Frontend changes-
Correctly handle schema errors that are returned from GraphQL - Example response -
Display an alert / warning (might need some UX input on the MR
backend - DONE (included in !143786 (merged))
Backend changesAdding safe navigation for the slug
field attributes seems to fix this
diff --git a/ee/app/models/product_analytics/visualization.rb b/ee/app/models/product_analytics/visualization.rb
index a276fd59cf16..fd4daa691935 100644
--- a/ee/app/models/product_analytics/visualization.rb
+++ b/ee/app/models/product_analytics/visualization.rb
@@ -98,7 +98,7 @@ def initialize_with_error(init_error, slug)
@type = 'unknown'
@data = {}
@errors = [init_error]
- @slug = slug.parameterize.underscore
+ @slug = slug&.parameterize&.underscore
end
def initialize(config:, slug:, init_error: nil)
@@ -115,7 +115,7 @@ def initialize(config:, slug:, init_error: nil)
rescue Psych::Exception => e
@errors = [e.message]
end
- @slug = slug.parameterize.underscore
+ @slug = slug&.parameterize&.underscore
validate
end
Edited by Ezekiel Kigbo