Bug #17343
closedIt is not possible to use empty list as value for optional parameters via API
Description
Description of problem:
Some entities has optional array parameters that allow nil value. Previously it was possible to send empty list '[]' as value to clear all values, but now according to dLobatog it is not possible because of a new security mechanism in Rails.
Though it affects all the optional parameters, some example entities/parameters are: smart_proxies.locations, location.smart_proxies, organization.smart_proxies, organization.hostgroup_ids.
- Update with empty list
Making HTTP PUT request to https://sat6.com/katello/api/v2/organizations/39 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and data {"organization": {"smart_proxy_ids": []}}.
- Response
Received HTTP 200 response:
{
"name":"XWsKJtxSBN",
"id":39,
"smart_proxies":[
{
"name":"sat6.com",
"id":1,
"url":"https://sat6.com:9090"
},
{
"name":"Oa5c2S",
"id":11,
"url":"https://sat6.com:11629"
}
}
Steps to Reproduce:
1. Create entity that has optional array parameters
2. Update that parameter with some value
3. Update that parameter one more time with empty list
4. Check that values from point 2 not changed
Actual results:
When updating with empty list nothing happens, optional parameter has all previous values
Expected results:
All values should be cleared