roadmap icon indicating copy to clipboard operation
roadmap copied to clipboard

Guidance page returns a 500 error in specific scenario

Open briri opened this issue 1 year ago • 1 comments

Please complete the following fields as applicable:

What version of the DMPRoadmap code are you running? (e.g. v2.2.0) v3.1.1

Expected behaviour: The Admin -> Guidances loads

Actual behaviour: A 500 error is thrown when I have no Guidance Groups that are NOT 'optional subsets'

Steps to reproduce:

  • Login as an Org Admin.
  • Go to the Admin -> Guidance page
  • Make sure there is a Guidance Group whose name matches the Org abbreviation
  • Update all Guidance Groups so that the 'optional subset' flag is true
  • Navigate back to the Admin -> Guidance page if necessary

Diagnosis The controller attempts to create the default GuidanceGroup for the Org when none exists. This code though uses the Org abbreviation as the guidance group name. The guidance group model though requires that the name be unique. This cause the save/create to fail resulting in a 500 error https://github.com/DMPRoadmap/roadmap/blob/382e14f01a020c0fdc9009b8948fed83a0cddc02/app/controllers/guidances_controller.rb#L19

It would be better to prevent users from making all of the guidance groups 'optional subsets'. Change the view logic to NOT enable/display this flag if there is only one guidance group, or if there are no other guidance groups that are not 'optional subsets'

briri avatar Aug 04 '22 21:08 briri