Bug #22326
closedAPI gives subtotal=0 when per_page=0 and thin=true and search string is used
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1516929
Description of problem:
API gives subtotal=0 when per_page=0 and search string is used
Version-Release number of selected component (if applicable):
6.2.11
How reproducible:
Everytime
Steps to Reproduce:
1. Install sat6 server
2. Define two hosts test1 & test2
3. run curl -u admin:xxx -X GET 'https://sat6/api/v2/hosts?per_page=0&thin=true&search=name+~+"test"
Actual results:
{
"total": 3,
"subtotal": 0, <==============
"page": 1,
"per_page": 0,
"search": "name ~ \"test\"",
"sort": {
"by": null,
"order": null
},
"results": []
}
Expected results:
{
"total": 3,
"subtotal": 2, <==============
"page": 1,
"per_page": 0,
"search": "name ~ \"test\"",
"sort": {
"by": null,
"order": null
},
"results": []
}
Additional info:
Different combinations give correct "subtotal":
without thin=true:
curl -u admin:xxx -X GET 'https://sat6/api/v2/hosts?per_page=0&search=name+~+"test"'
{
"total": 3,
"subtotal": 2,
"page": 1,
"per_page": 0,
"search": "name ~ \"test\"",
"sort": {
"by": null,
"order": null
},
"results": []
}
without search:
curl -u admin:xxx -X GET 'https://sat6/api/v2/hosts?per_page=0&thin=true'
{
"total": 3,
"subtotal": 3,
"page": 1,
"per_page": 0,
"search": null,
"sort": {
"by": null,
"order": null
},
"results": []
}
without per_page:
curl -u admin:xxx -X GET 'https://sat6/api/v2/hosts?thin=true&search=name+~+"test"'
{
"total": 3,
"subtotal": 2,
"page": 1,
"per_page": 20,
"search": "name ~ \"test\"",
"sort": {
"by": null,
"order": null
},
"results": [{"id":2,"name":"test1"},{"id":3,"name":"test2"}]
Updated by Andrew F almost 7 years ago
- Subject changed from API gives subtotal=0 when per_page=0 and thin=true and search string is used to API gives subtotal=0 when per_page=0 and thin=true and search string is used
Seeing a similar issue in Foreman 1.16.0, where the subtotal value returned is equal to the per_page value when using trim=true
and the returned results exceeds the per_page value.
/api/v2/hosts?search=hostgroup_title+~+rabbitmq&per_page=50
{ "total": 12174, "subtotal": 66, "page": 1, "per_page": 50, "search": "hostgroup_title ~ rabbitmq", "sort": { "by": null, "order": null }, "results": [...] }
/api/v2/hosts?search=hostgroup_title+~+rabbitmq&per_page=50&thin=true
{ "total": 12174, "subtotal": 50, "page": 1, "per_page": 50, "search": "hostgroup_title ~ rabbitmq", "sort": { "by": null, "order": null }, "results": [...] }
/api/v2/hosts?search=hostgroup_title+~+rabbitmq&per_page=100&thin=true
{ "total": 12174, "subtotal": 66, "page": 1, "per_page": 100, "search": "hostgroup_title ~ rabbitmq", "sort": { "by": null, "order": null }, "results": [...] }
Updated by Amit Karsale over 6 years ago
- Status changed from New to Closed
- Pull request https://github.com/theforeman/foreman/pull/5713 added
duplicate bug here(fixed): https://projects.theforeman.org/issues/23599
Updated by Tomer Brisker over 6 years ago
- Status changed from Closed to Duplicate
Updated by Tomer Brisker over 6 years ago
- Is duplicate of Bug #23599: Getting hosts via API with thin=true returns wrong subtotal value added