Project

General

Profile

Actions

Bug #18855

closed

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

Added by Tomáš Strachota almost 7 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
Users, Roles and Permissions
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

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 1 (0 open1 closed)

Related to Foreman - Feature #18317: Clone role from APIClosedOndřej Pražák01/31/2017Actions
Actions #1

Updated by Tomáš Strachota almost 7 years ago

Actions #2

Updated by Marek Hulán almost 7 years 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.

Actions #3

Updated by Marek Hulán almost 7 years ago

  • Target version changed from 1.12.1 to 1.12.3
Actions #4

Updated by Marek Hulán almost 7 years ago

  • Target version changed from 1.12.3 to 1.13.0
Actions #5

Updated by Marek Hulán almost 7 years ago

  • Target version changed from 1.13.0 to 1.13.2
Actions #6

Updated by Marek Hulán almost 7 years ago

  • Target version changed from 1.13.2 to 1.13.4
Actions #7

Updated by Tomáš Strachota almost 7 years ago

The role seems to be valid and I'm able to clone it via UI. Api or hammer fails.

Actions #8

Updated by The Foreman Bot over 6 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4560 added
Actions #9

Updated by Marek Hulán over 6 years ago

  • Target version changed from 1.13.4 to 1.14.0
Actions #10

Updated by Marek Hulán over 6 years ago

  • Bugzilla link set to 1444216
Actions #11

Updated by Marek Hulán over 6 years ago

  • translation missing: en.field_release set to 266

Daniel, I think this would be also good in 1.15.2. It's not regression introduced in 1.15 but since one of areas that 1.15 is focused on is the delegation of administration for organizations, this would hit a lot of users. It's small and safe patch. As always, feel free to reset to 1.16 if you think otherwise.

Actions #12

Updated by Ondřej Pražák over 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #13

Updated by Tomer Brisker over 3 years ago

  • Category changed from 218 to Users, Roles and Permissions
Actions

Also available in: Atom PDF