I started playing around with the latest of foreman, katello,
hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
When I try and run it with everyting… I get the following
undefined method []' for nil:NilClass (NoMethodError) /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:inparams_match_database'
/home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in block (3 levels) in _run__1169786742890763799__process_action__3600662518651395552__callbacks' /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:inblock in _conditional_callback_around_1715'
/home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in around' /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in_callback_around_1267'
/home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in _conditional_callback_around_1715' /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:inblock (2 levels) in
_run__1169786742890763799__process_action__3600662518651395552__callbacks'
/home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in block in _conditional_callback_around_1714' /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:inclear_thread'
This seems to be because the katello command passes up passses up
{"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
"controller"=>"katello/api/v2/organizations"}
Looks like all my code is missing the outside wrappers… is this a
setting I missed?
– bk
···
On 01/21/2014 08:19 PM, Bryan Kearney wrote:
> I started playing around with the latest of foreman, katello,
> hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
>
> When I try and run it with everyting.. I get the following
>
> undefined method `[]' for nil:NilClass (NoMethodError)
> /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:in
> `params_match_database'
> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in
> `block (3 levels) in
> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> `block in _conditional_callback_around_1715'
> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in
> `around'
> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in
> `_callback_around_1267'
> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in
> `_conditional_callback_around_1715'
> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:in
> `block (2 levels) in
> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> `block in _conditional_callback_around_1714'
> /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:in
> `clear_thread'
>
>
> This seems to be because the katello command passes up passses up
> {"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
> "controller"=>"katello/api/v2/organizations"}
>
>
> while the foreman cli passes up;
>
> {"organization"=>{"name"=>"fred3"}, "format"=>"json", "apiv"=>"v2",
> "action"=>"create", "controller"=>"api/v2/organizations"}
>
> Did I miss something?
>
>
> -- bk
>
Just a guess, I'm not sure about katello API conventions, but from other
controllers it seems it does not use the wrapped params format.
The bug comes from foreman org API complaining about params (probably
not being wrapped as you suggest).
The API param structure is defined by api docs which defines the params
as not wrapper. Compare docs for org create
If you want to keep API params consistent on Katello side, you'll have
to translate params to nested format in the Katello API controller
before calling super.
HTH,
Martin
···
On 01/22/2014 02:31 AM, Bryan Kearney wrote:
> On 01/21/2014 08:19 PM, Bryan Kearney wrote:
>> I started playing around with the latest of foreman, katello,
>> hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
>>
>> When I try and run it with everyting.. I get the following
>>
>> undefined method `[]' for nil:NilClass (NoMethodError)
>> /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:in
>>
>> `params_match_database'
>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in
>>
>> `block (3 levels) in
>> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
>>
>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
>>
>> `block in _conditional_callback_around_1715'
>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in
>>
>> `around'
>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in
>>
>> `_callback_around_1267'
>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in
>>
>> `_conditional_callback_around_1715'
>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:in
>>
>> `block (2 levels) in
>> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
>>
>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
>>
>> `block in _conditional_callback_around_1714'
>> /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:in
>>
>> `clear_thread'
>>
>>
>> This seems to be because the katello command passes up passses up
>> {"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
>> "controller"=>"katello/api/v2/organizations"}
>>
>>
>> while the foreman cli passes up;
>>
>> {"organization"=>{"name"=>"fred3"}, "format"=>"json", "apiv"=>"v2",
>> "action"=>"create", "controller"=>"api/v2/organizations"}
>>
>> Did I miss something?
>>
>>
>> -- bk
>>
> Looks like all my code is missing the outside wrappers.. is this a
> setting I missed?
>
> -- bk
>
I think this is due to a before filter, so I assume it needs to be made
consistent or we override all before filters.
I thouhgt this had been resolved? One consistent API. Am I wrong on this?
Adam, can you please take a look at this in the morning.
– bk
···
On 01/22/2014 05:45 AM, Martin Bačovský wrote:
> On 01/22/2014 02:31 AM, Bryan Kearney wrote:
>> On 01/21/2014 08:19 PM, Bryan Kearney wrote:
>>> I started playing around with the latest of foreman, katello,
>>> hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
>>>
>>> When I try and run it with everyting.. I get the following
>>>
>>> undefined method `[]' for nil:NilClass (NoMethodError)
>>> /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:in
>>>
>>> `params_match_database'
>>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in
>>>
>>> `block (3 levels) in
>>> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
>>>
>>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
>>>
>>> `block in _conditional_callback_around_1715'
>>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in
>>>
>>> `around'
>>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in
>>>
>>> `_callback_around_1267'
>>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in
>>>
>>> `_conditional_callback_around_1715'
>>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:in
>>>
>>> `block (2 levels) in
>>> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
>>>
>>> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
>>>
>>> `block in _conditional_callback_around_1714'
>>> /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:in
>>>
>>> `clear_thread'
>>>
>>>
>>> This seems to be because the katello command passes up passses up
>>> {"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
>>> "controller"=>"katello/api/v2/organizations"}
>>>
>>>
>>> while the foreman cli passes up;
>>>
>>> {"organization"=>{"name"=>"fred3"}, "format"=>"json", "apiv"=>"v2",
>>> "action"=>"create", "controller"=>"api/v2/organizations"}
>>>
>>> Did I miss something?
>>>
>>>
>>> -- bk
>>>
>> Looks like all my code is missing the outside wrappers.. is this a
>> setting I missed?
>>
>> -- bk
>>
> Just a guess, I'm not sure about katello API conventions, but from other
> controllers it seems it does not use the wrapped params format.
>
> The bug comes from foreman org API complaining about params (probably
> not being wrapped as you suggest).
>
> The API param structure is defined by api docs which defines the params
> as not wrapper. Compare docs for org create
>
> https://github.com/Katello/katello/blob/master/app/controllers/katello/api/v2/organizations_controller.rb
>
> https://github.com/theforeman/foreman/blob/develop/app/controllers/concerns/api/v2/taxonomies_controller.rb
>
>
> If you want to keep API params consistent on Katello side, you'll have
> to translate params to nested format in the Katello API controller
> before calling super.
>
> HTH,
> Martin
>
···
----- Original Message -----
> From: "Martin Bačovský"
> To: foreman-dev@googlegroups.com
> Sent: Wednesday, January 22, 2014 5:45:27 AM
> Subject: Re: [foreman-dev] Org creation is busted form hammer with both katello and cli
>
> On 01/22/2014 02:31 AM, Bryan Kearney wrote:
> > On 01/21/2014 08:19 PM, Bryan Kearney wrote:
> >> I started playing around with the latest of foreman, katello,
> >> hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
> >>
> >> When I try and run it with everyting.. I get the following
> >>
> >> undefined method `[]' for nil:NilClass (NoMethodError)
> >> /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:in
> >>
> >> `params_match_database'
> >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in
> >>
> >> `block (3 levels) in
> >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> >>
> >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> >>
> >> `block in _conditional_callback_around_1715'
> >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in
> >>
> >> `around'
> >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in
> >>
> >> `_callback_around_1267'
> >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in
> >>
> >> `_conditional_callback_around_1715'
> >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:in
> >>
> >> `block (2 levels) in
> >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> >>
> >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> >>
> >> `block in _conditional_callback_around_1714'
> >> /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:in
> >>
> >> `clear_thread'
> >>
> >>
> >> This seems to be because the katello command passes up passses up
> >> {"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
> >> "controller"=>"katello/api/v2/organizations"}
> >>
> >>
> >> while the foreman cli passes up;
> >>
> >> {"organization"=>{"name"=>"fred3"}, "format"=>"json", "apiv"=>"v2",
> >> "action"=>"create", "controller"=>"api/v2/organizations"}
> >>
> >> Did I miss something?
> >>
> >>
> >> -- bk
> >>
> > Looks like all my code is missing the outside wrappers.. is this a
> > setting I missed?
> >
> > -- bk
> >
> Just a guess, I'm not sure about katello API conventions, but from other
> controllers it seems it does not use the wrapped params format.
>
> The bug comes from foreman org API complaining about params (probably
> not being wrapped as you suggest).
>
> The API param structure is defined by api docs which defines the params
> as not wrapper. Compare docs for org create
>
> https://github.com/Katello/katello/blob/master/app/controllers/katello/api/v2/organizations_controller.rb
> https://github.com/theforeman/foreman/blob/develop/app/controllers/concerns/api/v2/taxonomies_controller.rb
>
> If you want to keep API params consistent on Katello side, you'll have
> to translate params to nested format in the Katello API controller
> before calling super.
>
> HTH,
> Martin
>
> --
> You received this message because you are subscribed to the Google Groups
> "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to foreman-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
This is actually the problem we're hitting right now (see my wrap_parameters email). It looks like hammer is submitting wrapped parameters for foreman requests but not katello requests which makes sense. However, I thought wrap_parameters would take care of it but it looks like the content type is "application/x-www-form-urlencoded" and not json. So therefore our code is expecting wrapped params with a root node but there's none.
Optimally, I'd like to do the same thing as foreman here and I've got no qualms with using a root node on POST/PUT requests. That said, I forsee two problems. First, it conflicts with what the v2 documentation says:
Secondly, we'd have to investigate aligning our Nutupane UI code with it (or at least make the decision that we're not going to follow our API docs when using AngularJS–perhaps Walden or Eric can weigh in here).
David
···
----- Original Message -----
> From: "Tom McKay"
> To: foreman-dev@googlegroups.com
> Sent: Wednesday, January 22, 2014 12:44:39 PM
> Subject: Re: [foreman-dev] Org creation is busted form hammer with both katello and cli
>
>
>
> ----- Original Message -----
> > From: "Martin Bačovský"
> > To: foreman-dev@googlegroups.com
> > Sent: Wednesday, January 22, 2014 5:45:27 AM
> > Subject: Re: [foreman-dev] Org creation is busted form hammer with both
> > katello and cli
> >
> > On 01/22/2014 02:31 AM, Bryan Kearney wrote:
> > > On 01/21/2014 08:19 PM, Bryan Kearney wrote:
> > >> I started playing around with the latest of foreman, katello,
> > >> hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
> > >>
> > >> When I try and run it with everyting.. I get the following
> > >>
> > >> undefined method `[]' for nil:NilClass (NoMethodError)
> > >> /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:in
> > >>
> > >> `params_match_database'
> > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in
> > >>
> > >> `block (3 levels) in
> > >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> > >>
> > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> > >>
> > >> `block in _conditional_callback_around_1715'
> > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in
> > >>
> > >> `around'
> > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in
> > >>
> > >> `_callback_around_1267'
> > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in
> > >>
> > >> `_conditional_callback_around_1715'
> > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:in
> > >>
> > >> `block (2 levels) in
> > >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> > >>
> > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> > >>
> > >> `block in _conditional_callback_around_1714'
> > >> /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:in
> > >>
> > >> `clear_thread'
> > >>
> > >>
> > >> This seems to be because the katello command passes up passses up
> > >> {"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
> > >> "controller"=>"katello/api/v2/organizations"}
> > >>
> > >>
> > >> while the foreman cli passes up;
> > >>
> > >> {"organization"=>{"name"=>"fred3"}, "format"=>"json", "apiv"=>"v2",
> > >> "action"=>"create", "controller"=>"api/v2/organizations"}
> > >>
> > >> Did I miss something?
> > >>
> > >>
> > >> -- bk
> > >>
> > > Looks like all my code is missing the outside wrappers.. is this a
> > > setting I missed?
> > >
> > > -- bk
> > >
> > Just a guess, I'm not sure about katello API conventions, but from other
> > controllers it seems it does not use the wrapped params format.
> >
> > The bug comes from foreman org API complaining about params (probably
> > not being wrapped as you suggest).
> >
> > The API param structure is defined by api docs which defines the params
> > as not wrapper. Compare docs for org create
> >
> > https://github.com/Katello/katello/blob/master/app/controllers/katello/api/v2/organizations_controller.rb
> > https://github.com/theforeman/foreman/blob/develop/app/controllers/concerns/api/v2/taxonomies_controller.rb
> >
> > If you want to keep API params consistent on Katello side, you'll have
> > to translate params to nested format in the Katello API controller
> > before calling super.
> >
> > HTH,
> > Martin
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "foreman-dev" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to foreman-dev+unsubscribe@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
>
> Wait, is this just an apipie issue or is there really a code issue here?
>
> == foreman ==
>
> def_param_group :resource do
> param :resource, Hash, :action_aware => true do
> param :name, String, :required => true
> end
> end
>
> api :POST, '/:resource_id', 'Create :a_resource'
> param_group :resource, :as => :create
> def create
> @taxonomy = taxonomy_class.new(params[taxonomy_single.to_sym])
> instance_variable_set("@#{taxonomy_single}", @taxonomy)
> process_response @taxonomy.save
> end
>
> == katello ==
>
> api :POST, '/organizations', 'Create organization'
> param :name, String, :desc => "name", :required => true
> param :label, String, :desc => "unique label"
> param :description, String, :desc => "description"
> def create
> super
> end
>
> --
> You received this message because you are subscribed to the Google Groups
> "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to foreman-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
I thought of some other options last night that could solve this problem. In summary, here are the options:
Have hammer send json instead of application/x-www-form-urlencoded. Currently only json triggers wrap_parameters (http://goo.gl/XCwJYu)
Add more formats to wrap_parameters (not sure of the implications here)
Redo our code to use the params without being wrapped.
And again, update the apidoc in katello to use wrapped params (which I mentioned in the last email)
David
···
----- Original Message -----
> From: "David Davis"
> To: foreman-dev@googlegroups.com
> Sent: Thursday, January 23, 2014 6:44:52 PM
> Subject: Re: [foreman-dev] Org creation is busted form hammer with both katello and cli
>
> This is actually the problem we're hitting right now (see my wrap_parameters
> email). It looks like hammer is submitting wrapped parameters for foreman
> requests but not katello requests which makes sense. However, I thought
> wrap_parameters would take care of it but it looks like the content type is
> "application/x-www-form-urlencoded" and not json. So therefore our code is
> expecting wrapped params with a root node but there's none.
>
> Optimally, I'd like to do the same thing as foreman here and I've got no
> qualms with using a root node on POST/PUT requests. That said, I forsee two
> problems. First, it conflicts with what the v2 documentation says:
>
> ... { "name":"foo.bar.com","fullname":"foo.bar.com description" } ...
> (http://theforeman.org/manuals/1.4/index.html#5.1.1CRUDRequestExamples)
>
> Secondly, we'd have to investigate aligning our Nutupane UI code with it (or
> at least make the decision that we're not going to follow our API docs when
> using AngularJS--perhaps Walden or Eric can weigh in here).
>
> David
>
> ----- Original Message -----
> > From: "Tom McKay"
> > To: foreman-dev@googlegroups.com
> > Sent: Wednesday, January 22, 2014 12:44:39 PM
> > Subject: Re: [foreman-dev] Org creation is busted form hammer with both
> > katello and cli
> >
> >
> >
> > ----- Original Message -----
> > > From: "Martin Bačovský"
> > > To: foreman-dev@googlegroups.com
> > > Sent: Wednesday, January 22, 2014 5:45:27 AM
> > > Subject: Re: [foreman-dev] Org creation is busted form hammer with both
> > > katello and cli
> > >
> > > On 01/22/2014 02:31 AM, Bryan Kearney wrote:
> > > > On 01/21/2014 08:19 PM, Bryan Kearney wrote:
> > > >> I started playing around with the latest of foreman, katello,
> > > >> hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
> > > >>
> > > >> When I try and run it with everyting.. I get the following
> > > >>
> > > >> undefined method `[]' for nil:NilClass (NoMethodError)
> > > >> /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:in
> > > >>
> > > >> `params_match_database'
> > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in
> > > >>
> > > >> `block (3 levels) in
> > > >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> > > >>
> > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> > > >>
> > > >> `block in _conditional_callback_around_1715'
> > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in
> > > >>
> > > >> `around'
> > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in
> > > >>
> > > >> `_callback_around_1267'
> > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in
> > > >>
> > > >> `_conditional_callback_around_1715'
> > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:in
> > > >>
> > > >> `block (2 levels) in
> > > >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> > > >>
> > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> > > >>
> > > >> `block in _conditional_callback_around_1714'
> > > >> /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:in
> > > >>
> > > >> `clear_thread'
> > > >>
> > > >>
> > > >> This seems to be because the katello command passes up passses up
> > > >> {"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
> > > >> "controller"=>"katello/api/v2/organizations"}
> > > >>
> > > >>
> > > >> while the foreman cli passes up;
> > > >>
> > > >> {"organization"=>{"name"=>"fred3"}, "format"=>"json", "apiv"=>"v2",
> > > >> "action"=>"create", "controller"=>"api/v2/organizations"}
> > > >>
> > > >> Did I miss something?
> > > >>
> > > >>
> > > >> -- bk
> > > >>
> > > > Looks like all my code is missing the outside wrappers.. is this a
> > > > setting I missed?
> > > >
> > > > -- bk
> > > >
> > > Just a guess, I'm not sure about katello API conventions, but from other
> > > controllers it seems it does not use the wrapped params format.
> > >
> > > The bug comes from foreman org API complaining about params (probably
> > > not being wrapped as you suggest).
> > >
> > > The API param structure is defined by api docs which defines the params
> > > as not wrapper. Compare docs for org create
> > >
> > > https://github.com/Katello/katello/blob/master/app/controllers/katello/api/v2/organizations_controller.rb
> > > https://github.com/theforeman/foreman/blob/develop/app/controllers/concerns/api/v2/taxonomies_controller.rb
> > >
> > > If you want to keep API params consistent on Katello side, you'll have
> > > to translate params to nested format in the Katello API controller
> > > before calling super.
> > >
> > > HTH,
> > > Martin
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "foreman-dev" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an
> > > email to foreman-dev+unsubscribe@googlegroups.com.
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> >
> > Wait, is this just an apipie issue or is there really a code issue here?
> >
> > == foreman ==
> >
> > def_param_group :resource do
> > param :resource, Hash, :action_aware => true do
> > param :name, String, :required => true
> > end
> > end
> >
> > api :POST, '/:resource_id', 'Create :a_resource'
> > param_group :resource, :as => :create
> > def create
> > @taxonomy = taxonomy_class.new(params[taxonomy_single.to_sym])
> > instance_variable_set("@#{taxonomy_single}", @taxonomy)
> > process_response @taxonomy.save
> > end
> >
> > == katello ==
> >
> > api :POST, '/organizations', 'Create organization'
> > param :name, String, :desc => "name", :required => true
> > param :label, String, :desc => "unique label"
> > param :description, String, :desc => "description"
> > def create
> > super
> > end
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "foreman-dev" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to foreman-dev+unsubscribe@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "foreman-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to foreman-dev+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
···
On 01/24/2014 07:17 AM, David Davis wrote:
> I thought of some other options last night that could solve this problem. In summary, here are the options:
>
> 1) Have hammer send json instead of application/x-www-form-urlencoded. Currently only json triggers wrap_parameters (http://goo.gl/XCwJYu)
> 2) Add more formats to wrap_parameters (not sure of the implications here)
> 3) Redo our code to use the params without being wrapped.
> 4) And again, update the apidoc in katello to use wrapped params (which I mentioned in the last email)
>
> David
>
> ----- Original Message -----
> > From: "David Davis"
> > To: foreman-dev@googlegroups.com
> > Sent: Thursday, January 23, 2014 6:44:52 PM
> > Subject: Re: [foreman-dev] Org creation is busted form hammer with both katello and cli
> >
> > This is actually the problem we're hitting right now (see my wrap_parameters
> > email). It looks like hammer is submitting wrapped parameters for foreman
> > requests but not katello requests which makes sense. However, I thought
> > wrap_parameters would take care of it but it looks like the content type is
> > "application/x-www-form-urlencoded" and not json. So therefore our code is
> > expecting wrapped params with a root node but there's none.
> >
> > Optimally, I'd like to do the same thing as foreman here and I've got no
> > qualms with using a root node on POST/PUT requests. That said, I forsee two
> > problems. First, it conflicts with what the v2 documentation says:
> >
> > ... { "name":"foo.bar.com","fullname":"foo.bar.com description" } ...
> > (http://theforeman.org/manuals/1.4/index.html#5.1.1CRUDRequestExamples)
> >
> > Secondly, we'd have to investigate aligning our Nutupane UI code with it (or
> > at least make the decision that we're not going to follow our API docs when
> > using AngularJS--perhaps Walden or Eric can weigh in here).
> >
> > David
> >
> > ----- Original Message -----
> > > From: "Tom McKay"
> > > To: foreman-dev@googlegroups.com
> > > Sent: Wednesday, January 22, 2014 12:44:39 PM
> > > Subject: Re: [foreman-dev] Org creation is busted form hammer with both
> > > katello and cli
> > >
> > >
> > >
> > > ----- Original Message -----
> > > > From: "Martin Bačovský"
> > > > To: foreman-dev@googlegroups.com
> > > > Sent: Wednesday, January 22, 2014 5:45:27 AM
> > > > Subject: Re: [foreman-dev] Org creation is busted form hammer with both
> > > > katello and cli
> > > >
> > > > On 01/22/2014 02:31 AM, Bryan Kearney wrote:
> > > > > On 01/21/2014 08:19 PM, Bryan Kearney wrote:
> > > > >> I started playing around with the latest of foreman, katello,
> > > > >> hammer-cli, hammer-cli-foreman, and hammer-cli-katello.
> > > > >>
> > > > >> When I try and run it with everyting.. I get the following
> > > > >>
> > > > >> undefined method `[]' for nil:NilClass (NoMethodError)
> > > > >> /home/bkearney/code/foreman/app/controllers/concerns/api/v2/taxonomies_controller.rb:75:in
> > > > >>
> > > > >> `params_match_database'
> > > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:465:in
> > > > >>
> > > > >> `block (3 levels) in
> > > > >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> > > > >>
> > > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> > > > >>
> > > > >> `block in _conditional_callback_around_1715'
> > > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:326:in
> > > > >>
> > > > >> `around'
> > > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:310:in
> > > > >>
> > > > >> `_callback_around_1267'
> > > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:214:in
> > > > >>
> > > > >> `_conditional_callback_around_1715'
> > > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:449:in
> > > > >>
> > > > >> `block (2 levels) in
> > > > >> _run__1169786742890763799__process_action__3600662518651395552__callbacks'
> > > > >>
> > > > >> /home/bkearney/.rvm/gems/ruby-1.9.3-p484/gems/activesupport-3.2.16/lib/active_support/callbacks.rb:215:in
> > > > >>
> > > > >> `block in _conditional_callback_around_1714'
> > > > >> /home/bkearney/code/foreman/app/models/concerns/foreman/thread_session.rb:33:in
> > > > >>
> > > > >> `clear_thread'
> > > > >>
> > > > >>
> > > > >> This seems to be because the katello command passes up passses up
> > > > >> {"name"=>"fred3", "api_version"=>"v2", "action"=>"create",
> > > > >> "controller"=>"katello/api/v2/organizations"}
> > > > >>
> > > > >>
> > > > >> while the foreman cli passes up;
> > > > >>
> > > > >> {"organization"=>{"name"=>"fred3"}, "format"=>"json", "apiv"=>"v2",
> > > > >> "action"=>"create", "controller"=>"api/v2/organizations"}
> > > > >>
> > > > >> Did I miss something?
> > > > >>
> > > > >>
> > > > >> -- bk
> > > > >>
> > > > > Looks like all my code is missing the outside wrappers.. is this a
> > > > > setting I missed?
> > > > >
> > > > > -- bk
> > > > >
> > > > Just a guess, I'm not sure about katello API conventions, but from other
> > > > controllers it seems it does not use the wrapped params format.
> > > >
> > > > The bug comes from foreman org API complaining about params (probably
> > > > not being wrapped as you suggest).
> > > >
> > > > The API param structure is defined by api docs which defines the params
> > > > as not wrapper. Compare docs for org create
> > > >
> > > > https://github.com/Katello/katello/blob/master/app/controllers/katello/api/v2/organizations_controller.rb
> > > > https://github.com/theforeman/foreman/blob/develop/app/controllers/concerns/api/v2/taxonomies_controller.rb
> > > >
> > > > If you want to keep API params consistent on Katello side, you'll have
> > > > to translate params to nested format in the Katello API controller
> > > > before calling super.
> > > >
> > > > HTH,
> > > > Martin
> > > >
> > > > --
> > > > You received this message because you are subscribed to the Google Groups
> > > > "foreman-dev" group.
> > > > To unsubscribe from this group and stop receiving emails from it, send an
> > > > email to foreman-dev+unsubscribe@googlegroups.com.
> > > > For more options, visit https://groups.google.com/groups/opt_out.
> > > >
> > >
> > > Wait, is this just an apipie issue or is there really a code issue here?
> > >
> > > == foreman ==
> > >
> > > def_param_group :resource do
> > > param :resource, Hash, :action_aware => true do
> > > param :name, String, :required => true
> > > end
> > > end
> > >
> > > api :POST, '/:resource_id', 'Create :a_resource'
> > > param_group :resource, :as => :create
> > > def create
> > > @taxonomy = taxonomy_class.new(params[taxonomy_single.to_sym])
> > > instance_variable_set("@#{taxonomy_single}", @taxonomy)
> > > process_response @taxonomy.save
> > > end
> > >
> > > == katello ==
> > >
> > > api :POST, '/organizations', 'Create organization'
> > > param :name, String, :desc => "name", :required => true
> > > param :label, String, :desc => "unique label"
> > > param :description, String, :desc => "description"
> > > def create
> > > super
> > > end
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "foreman-dev" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an
> > > email to foreman-dev+unsubscribe@googlegroups.com.
> > > For more options, visit https://groups.google.com/groups/opt_out.
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "foreman-dev" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to foreman-dev+unsubscribe@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
>
> I thought of some other options last night that could solve this problem. In summary, here are the options:
>
> 1) Have hammer send json instead of application/x-www-form-urlencoded. Currently only json triggers wrap_parameters (http://goo.gl/XCwJYu)
So we agreed to do this in the meantime, reverting the changes to
foreman_api/katello_api.
> 2) Add more formats to wrap_parameters (not sure of the implications here)
We agreed to try this too, which would mean you can send form data to
the API without wrapping (#4180).
> 4) And again, update the apidoc in katello to use wrapped params (which I mentioned in the last email)
We agreed to remove the wrapping from Foreman's apidoc, as it's
inaccurate, since we automatically wrap everything. This means
foreman_api would then rely on wrapped_params entirely, whether it's
JSON or form data.