Fix Projects::Ml::CandidatesController#show - undefined method can?' for nil:NilClass (ActionView::Template::Error)`

What does this MR do and why?

Fix sentry error for anonymous users on Projects::Ml::CandidatesController#show - undefined method can?' for nil:NilClass (ActionView::Template::Error)`

Related to #513099 (closed)

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

How to set up and validate locally

  1. Go to any project, and "Analyze/Experiments.
  2. First create some experiments and runs as below on rails console
project = Project.find(34)
user = User.find_by_username('test4')

Ml::CreateModelService.new(project, "model_1", user).execute
m = ::Ml::Model.find_by(name: "model_1")
12.times { |i| Ml::CreateCandidateService.new(m.default_experiment, {user: user}).execute }


#  Add some ci info here
ca = Ml::Candidate.last
ca.update  ci_build:  Ci::Build.last
  1. You should assign a ci_build_id to some candidate.

Then navigate to the run as an anonymous user in browser's incognito mode for example

Edited by Alper Akgun

Merge request reports

Loading