Project

General

Profile

Actions

Bug #22326

closed

API gives subtotal=0 when per_page=0 and thin=true and search string is used

Added by Marek Hulán over 6 years ago. Updated over 5 years ago.

Status:
Duplicate
Priority:
Normal
Assignee:
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

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"}]


Related issues 1 (0 open1 closed)

Is duplicate of Foreman - Bug #23599: Getting hosts via API with thin=true returns wrong subtotal valueClosedAmir Fefer05/15/2018Actions
Actions #1

Updated by Andrew F almost 6 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": [...]
}

Actions #2

Updated by Amit Karsale almost 6 years ago

  • Assignee set to Amit Karsale
Actions #3

Updated by Amit Karsale almost 6 years ago

  • Status changed from New to Closed
  • Pull request https://github.com/theforeman/foreman/pull/5713 added
Actions #4

Updated by Tomer Brisker almost 6 years ago

  • Status changed from Closed to Duplicate
Actions #5

Updated by Tomer Brisker almost 6 years ago

  • Is duplicate of Bug #23599: Getting hosts via API with thin=true returns wrong subtotal value added
Actions #6

Updated by Tomer Brisker over 5 years ago

  • Category changed from 19 to API
Actions

Also available in: Atom PDF