Bug #18855

Role clone API call fails for roles with some organizations/locations assigned

Added by Tomáš Strachota 16 days ago. Updated 11 days ago.

Assigned To:Ondřej Pražák
Target version:Team Marek Iteration 12
Difficulty: Bugzilla link:
Found in release: Pull request:
Story points-
Velocity based estimate-


Steps to reproduce:
  1. Create a user role assigned to some organizations and locations
  2. Try to clone the role with either api or hammer

Cloning roles without any taxonomies work fine.

Actual results:
The API call fails on validation of the cloned record:

[ERROR 2017-03-09T14:11:07 API] 422 Unprocessable Entity
[DEBUG 2017-03-09T14:11:07 API] {
    "error" => {
                   "id" => nil,
               "errors" => {
                "locations" => [
                [0] "is invalid" 
            "organizations" => [
                [0] "is invalid" 
        "full_messages" => [
            [0] "Locations is invalid",
            [1] "Organizations is invalid" 

In fact the original validation error comes from taxonomies:

you cannot remove organizations that are used by hosts or inherited

Active record hides the message with a generic one for validation errors on associations.

Expected results:
The role should be successfully cloned with all taxonomies set.

Related issues

Related to Foreman - Feature #18317: Clone role from API Closed 01/31/2017


#1 Updated by Tomáš Strachota 16 days ago

#2 Updated by Marek Hulán 16 days ago

I remember to see this before, isn't this caused by the fact the original role that you try to clone is already invalid? That was it in my case.

#3 Updated by Marek Hulán 11 days ago

  • Target version changed from Team Marek Iteration 11 to Team Marek Iteration 12

Also available in: Atom PDF