Skip to content

Require project_name in all server requests #184

@alimi

Description

@alimi

All controllers inherit from Magma::Controller, and Magma::Controller assumes project_name will be included in request payloads.

class Magma
class Controller < Etna::Controller
def initialize(request, action=nil)
super
@project_name = @params[:project_name]
end
end
end

Magma::Controller doesn't check that project_name so if it's missing we'll see errors downstream like

WARN:2020-07-09T15:49:19+00:00 User saurabh.asthana@ucsf.edu calling update_model#action with params {:actions=>"[{:action_name=>\"add_attribute\", :type=>\"string\", :model_name=>\"project\", :attribute_name=>\"faq\", :description=>\"Frequently asked questions about COMET\", :di
splay_name=>\"FAQ\"}]"}
ERROR:2020-07-09T15:49:19+00:00 hxlkr Caught unspecified error
ERROR:2020-07-09T15:49:19+00:00 hxlkr undefined method `to_sym' for nil:NilClass
ERROR:2020-07-09T15:49:19+00:00 hxlkr /home/graft/magma/lib/magma.rb:31:in `get_project'
ERROR:2020-07-09T15:49:19+00:00 hxlkr /home/graft/magma/lib/magma/actions/model_update_actions.rb:68:in `initialize'
ERROR:2020-07-09T15:49:19+00:00 hxlkr /home/graft/magma/lib/magma/actions/model_update_actions.rb:10:in `new'
ERROR:2020-07-09T15:49:19+00:00 hxlkr /home/graft/magma/lib/magma/actions/model_update_actions.rb:10:in `build'
ERROR:2020-07-09T15:49:19+00:00 hxlkr /home/graft/magma/lib/magma/server/update_model.rb:6:in `action'

Magma::Controller should verify project_name is set and refers to an existing project. If those conditions aren't met, it should stop processing the request and respond with an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions