Bug 1544800 - Can Add Duplicate Custom Attributes on OpenShift Provider Via the API
Summary: Can Add Duplicate Custom Attributes on OpenShift Provider Via the API
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.9.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.10.0
Assignee: Gregg Tanzillo
QA Contact: Parthvi Vala
URL:
Whiteboard:
Depends On:
Blocks: 1552824
TreeView+ depends on / blocked
 
Reported: 2018-02-13 14:29 UTC by juwatts
Modified: 2019-02-11 14:00 UTC (History)
4 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1552824 (view as bug list)
Environment:
Last Closed: 2019-02-11 14:00:20 UTC
Category: ---
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description juwatts 2018-02-13 14:29:58 UTC
Description of problem:
When adding custom attributes via the api on the OpenShift provider, user has the ability to successfully add duplicate entries.


Version-Release number of selected component (if applicable):
5.9.0.20

How reproducible:
100%

Steps to Reproduce:
1. Add a custom attribute via the api
example:
POST /api/providers/1/custom_attributes
{
  "action" : "add",
  "resources" : [
    { "name" : "koko", "value" : "moko" }
  ]
}

2. Verify the custom attribute was added successfully
3. Add the same custom attribute via the api

Actual results:
Duplicate custom attributes appear

Expected results:
Would expect for some 409 returned code and json that explains that this custom attribute is already exists

Additional info:

Comment 3 CFME Bot 2018-02-14 13:45:36 UTC
New commit detected on ManageIQ/manageiq-api/master:
https://github.com/ManageIQ/manageiq-api/commit/5dff1e383aeef4d94befee7b3b17f3e44e6f2cf5

commit 5dff1e383aeef4d94befee7b3b17f3e44e6f2cf5
Author:     Jillian Tullo <jtullo>
AuthorDate: Wed Feb 14 07:37:45 2018 -0500
Commit:     Jillian Tullo <jtullo>
CommitDate: Wed Feb 14 07:37:45 2018 -0500

    Default section to "metadata" across custom attributes add action
    
    When a new custom attribute is added, it defaults the section to "metadata" when the section is not specified. This causes issues if the request is then made again, especially because the default behavior for "add" is to edit. Without defaulting the section to "metadata" across the board, a new custom attribute is created, rather than updated.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1544800

 .../api/subcollections/custom_attributes.rb          |  2 +-
 spec/requests/custom_attributes_spec.rb              | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

Comment 6 juwatts 2018-10-24 15:47:27 UTC
Verified on 5.10.0.20.20181016163900_fe677b4 that adding a custom attribute with the same name as an existing attribute updates the existing attribute.


Note You need to log in before you can comment on or make changes to this bug.