Project

General

Profile

Actions

Bug #27057

open

Create external user group API fails when location or organization parameters are passed

Added by Alan Evans over 5 years ago. Updated over 5 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Create External User Group API fails when location or organization parameters are passed

I reflexively add --organization-id to pretty much everything I do w/ hammer so of course I ran hammer user-group external create --organization-id. I got the error shown in the output below and started to write this ticket.

# hammer auth-source ldap create \
  --name 'Test LDAP'  \
  --host foo.example.com
Auth source [Test LDAP] created.

# hammer user-group create \
  --organization-id 2 \
  --name "Cool Guys" 
User group [Cool Guys] created.

# hammer user-group external create \
  --auth-source-id 1 \
  --name "Cool Guys" \
  --user-group "Cool Guys" \
  --organization-id 2

Could not create external user group:
  Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs.

Out of curiosity I went back to the API docs and I noticed that location and organization are optional. So on a whim I tried adding the external user group without an organization... It worked

# hammer user-group external create \
  --auth-source-id 1 \
  --name "Cool Guys" \
  --user-group "Cool Guys" 

External user group created.

So I thought I'd try it with a location... It didn't work.

# hammer user-group external create \
  --auth-source-id 1 \
  --name "Cool Guys" \ 
  --user-group "Cool Guys" \
  --location-id 1

Could not create external user group:
  Internal Server Error: the server was unable to finish the request. This may be caused by unavailability of some required service, incorrect API call or a server-side bug. There may be more information in the server's logs.

From /var/log/foreman/production.log

2019-06-14T09:52:03 [I|app|9896e49f] Started POST "/api/usergroups/1/external_usergroups" for fe80::5054:ff:fe5e:a65d at 2019-06-14 09:52:03 -0600
2019-06-14T09:52:03 [I|app|9896e49f] Processing by Api::V2::ExternalUsergroupsController#create as JSON
2019-06-14T09:52:03 [I|app|9896e49f]   Parameters: {"organization_id"=>2, "external_usergroup"=>{"name"=>"Cool Guys", "auth_source_id"=>1}, "apiv"=>"v2", "user
group_id"=>"1"}
2019-06-14T09:52:03 [I|app|9896e49f] Authorized user admin(Admin User)
2019-06-14T09:52:03 [I|app|9896e49f] Current user set to admin (admin)
2019-06-14T09:52:03 [W|app|9896e49f] Action failed
NoMethodError: undefined method `external_usergroups' for #<Organization:0x00007fdb6c46a1a0>
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/attribute_methods.rb:430:in `method_missing'
/usr/share/foreman/app/controllers/api/v2/external_usergroups_controller.rb:39:in `create'

2019-06-14T10:02:16 [I|app|49710f2d] Started POST "/api/usergroups/1/external_usergroups" for fe80::5054:ff:fe5e:a65d at 2019-06-14 10:02:16 -0600
2019-06-14T10:02:16 [I|app|49710f2d] Processing by Api::V2::ExternalUsergroupsController#create as JSON
2019-06-14T10:02:16 [I|app|49710f2d]   Parameters: {"location_id"=>1, "external_usergroup"=>{"name"=>"Cool Guys", "auth_source_id"=>1}, "apiv"=>"v2", "usergrou
p_id"=>"1"}
2019-06-14T10:02:16 [I|app|49710f2d] Authorized user admin(Admin User)
2019-06-14T10:02:16 [I|app|49710f2d] Current user set to admin (admin)
2019-06-14T10:02:16 [W|app|49710f2d] Action failed
NoMethodError: undefined method `external_usergroups' for #<Location:0x00007fdb681323b0>
/opt/theforeman/tfm-ror52/root/usr/share/gems/gems/activemodel-5.2.1/lib/active_model/attribute_methods.rb:430:in `method_missing'
/usr/share/foreman/app/controllers/api/v2/external_usergroups_controller.rb:39:in `create'
Actions #1

Updated by James Jeffers over 5 years ago

  • Project changed from Katello to Foreman
  • Category changed from API to API
Actions #2

Updated by James Jeffers over 5 years ago

  • Found in Releases 1.22.0 added
  • Found in Releases deleted (Katello 3.12.0)
Actions

Also available in: Atom PDF