Bug #18855

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

Added by Tomáš Strachota 9 months ago. Updated 5 months ago.

Status:Closed
Priority:Normal
Assigned To:Ondřej Pražák
Category:Users
Target version:Team Marek Iteration 16
Difficulty: Bugzilla link:1444216
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4560
Story points-
Velocity based estimate-
Release1.15.2Release relationshipAuto

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

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

Associated revisions

Revision e620923c
Added by Ondřej Pražák 5 months ago

Fixes #18855 - Disable taxonomy validations for roles

Revision 92fc35be
Added by Ondřej Pražák 5 months ago

Fixes #18855 - Disable taxonomy validations for roles

(cherry picked from commit e620923c07f987b87f6c06299d961d97c184a9ff)

History

#1 Updated by Tomáš Strachota 9 months ago

#2 Updated by Marek Hulán 9 months 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 8 months ago

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

#4 Updated by Marek Hulán 8 months ago

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

#5 Updated by Marek Hulán 6 months ago

  • Target version changed from Team Marek Iteration 13 to Team Marek Iteration 14

#6 Updated by Marek Hulán 6 months ago

  • Target version changed from Team Marek Iteration 14 to Team Marek Iteration 15

#7 Updated by Tomáš Strachota 6 months ago

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

#8 Updated by The Foreman Bot 6 months ago

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

#9 Updated by Marek Hulán 5 months ago

  • Target version changed from Team Marek Iteration 15 to Team Marek Iteration 16

#10 Updated by Marek Hulán 5 months ago

  • Bugzilla link set to 1444216

#11 Updated by Marek Hulán 5 months ago

  • Release set to 1.15.2

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.

#12 Updated by Ondřej Pražák 5 months ago

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

Also available in: Atom PDF