chef / automate

Chef Automate provides a full suite of enterprise capabilities for maintaining continuous visibility into application, infrastructure, and security automation.
https://automate.chef.io/
Apache License 2.0
226 stars 113 forks source link

Profiles search endpoint pagination does not work #2616

Closed phiggins closed 4 years ago

phiggins commented 4 years ago

From slack:

My servicenow environment is running from the acceptance channel and I'm seeing some compliance API issues. The compliance/profiles/search API doesn't appear to return results when I search by name example search query

{
  "name": "ssh-baseline",
  "order": "ASC",
  "sort": "name",
  "page": 1,
  "per_page": 100
}
phiggins commented 4 years ago

Most likely a regression from #2367

phiggins commented 4 years ago

I don't think there is a bug here, just poor (non-existent) documentation leading to failed expectations. We just recently implemented the pagination behavior for that endpoint, previously the parameters were accepted for requests to that endpoint but they were just non-functional. The example request parameters posted above include page of 1 and per_page of 100, which means the request is for the second page of 100 results, that is results 101-200. Since there is only one profile matching that name, empty results are returned.

To fix this in the short term, there are two options:

vjeffrey commented 4 years ago

I know we've previously discussed that this endpoint uses page 0 as a starting point in standup. This might be a good example of this functionality biting us. A user of our api (@satellite15 ) made assumptions about the api's pagination params based on other compliance endpoints, and that api call was broken when pagination was implemented on the endpoint b/c it was implemented assuming a 0 index for the pagination.
While I understand some folks aren't big fans of starting at page 1 for pagination, and we haven't been great about standardizing fully in our api, it's a user facing feature, and if we think about it in literal terms, we're asking for the first page of content, not the zero-th. Let's talk with ux in standup -- we can always still change things so page 1 is the first page