gitlabr icon indicating copy to clipboard operation
gitlabr copied to clipboard

`gitlab` params `page` and `max_page` either behave incorrectly or are not documented as expected

Open ColinFay opened this issue 2 years ago • 1 comments

Validation

  • [ ]  When I use the param as documented, I'll get everything from GitLab

Tech

The doc for gitlab() states :

page: number of page of API response to get; if "all" (default),
          all pages (up to max_page parameter!) are queried
          successively and combined.

max_page: maximum number of pages to retrieve. Defaults to 10. This is
          an upper limit to prevent gitlabr getting stuck in retrieving
          an unexpectedly high number of entries (e.g. of a project
          list). It can be set to NA/Inf to retrieve all available
          pages without limit, but this is recommended only under
          controlled circumstances.

So we would expect page = "all", max_page = NA to return everything. But this is not what happens — I'll get more pages with the default params than with what page = "all", max_page = NA

> gitlab(
+   req = "projects",
+   verb = httr::GET,
+   page = "all",
+   max_page = NA
+ ) |> nrow()
[1] 20

versus :

> gitlab(
+   req = "projects",
+   verb = httr::GET
+ ) |> nrow()
[1] 200

and

gitlab(
  req = "projects",
  verb = httr::GET, 
  max_page = 100
) |> nrow()
[1] 476

ColinFay avatar Jan 25 '23 07:01 ColinFay

My short exploration leads to :

if (page == "all") {
  pages_retrieved <- 1L
  while (length(resp$nxt) > 0 && is.finite(max_page) &&  pages_retrieved < max_page) {

Given that

> is.finite(NA)
[1] FALSE

This should be why it stops here

ColinFay avatar Jan 25 '23 07:01 ColinFay