r-lib / gh

Minimalistic GitHub API client in R
https://gh.r-lib.org
Other
223 stars 52 forks source link

`.limit = Inf` throwing formatting error on some repos #196

Closed cansavvy closed 2 months ago

cansavvy commented 5 months ago

First off, really appreciate this package, I'm using it inside another package, and its been great!

Summary of problem

I'm having a mysterious issue when it comes to calling gh::gh() with .limit = Inf. But unfortunately it is inconsistent for different repos which makes it difficult for me to make a reprex for. If I remove the .limit = Inf argument from below or change it to a very large number like 100000 it works just fine.

  result <- gh::gh( "GET /repos/{owner}/{repo}/activity",
    owner = "jhudsl",
    repo = "OTTR_Template",
    .token = token, 
    .limit = Inf
  )

Note this doesn't happen with every repository, I did this same call with a different repository that is newer (has less activity) and it ran fine. The only possible pattern I notice is that the repo it fails on has a lot of activity for a few years???

The error message looks like a formatting error but I'm not sure why?

<rlib_error_3_0/rlib_error/error>
Error in `"id" %in% names(args)`:
! Could not evaluate cli `{}` expression: `cli::pb_eta`.
Caused by error in `(function (fmt, ...) …`:
! invalid format '%2d'; use format %f, %e, %g or %a for numeric objects
---
Backtrace:
 1. gh::gh("GET /repos/{owner}/{repo}/activity", owner = "jhudsl", …
 2. cli::cli_progress_update()
 3. h$add(pb, .envir = .envir)
 4. cli::cli_status(bar$format, msg_done = bar$format_done %||% bar$format, …
 5. cli:::cli__message("status", list(id = id, msg = glue_cmd(msg, .envir = .envir…
 6. "id" %in% names(args)
 7. cli:::glue_cmd(msg, .envir = .envir)
 8. cli:::glue(str, .envir = .envir, .transformer = transformer, .cli = TRUE, …
 9. (function (expr) …
10. .transformer(expr, .envir) %||% character()
11. local .transformer(expr, .envir)
12. eval(expr, envir = envir) %??% cli_error(call. = caller, "Could not eval…
13. cli:::chain_error(expr, err, srcref = utils::getSrcref(sys.call()))
14. | base::withCallingHandlers({ …
15. base::eval(expr, envir = envir)
16. base::eval(expr, envir = envir)
17. (function (pb = getOption("cli__pb")) …
18. format_time_ago$vague_dt(eta, format = "terse")
19. base::eval(p$s, pieces)
20. base::eval(p$s, pieces)
21. "%2dy" %s% round(years)
22. base::do.call(sprintf, c(list(lhs), as.list(rhs)))
23. base::(function (fmt, ...) …
24. base::.handleSimpleError(function (e) …
25. | local h(simpleError(msg, call))
26. | cli:::throw_error(err, parent = e)

Any thoughts? Happy to help dig into things but I'm a bit at a lost of where to go next.

Session Info:

R version 4.3.1 (2023-06-16)
Platform: x86_64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.5.2

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] metricminer_0.5.1 testthat_3.2.1   

loaded via a namespace (and not attached):
 [1] httr2_1.0.1         htmlwidgets_1.6.4   devtools_2.4.5      remotes_2.5.0      
 [5] gh_1.4.1            gargle_1.5.2        vctrs_0.6.5         tools_4.3.1        
 [9] generics_0.1.3      curl_5.2.1          tibble_3.2.1        fansi_1.0.6        
[13] pkgconfig_2.0.3     desc_1.4.3          assertthat_0.2.1    lifecycle_1.0.4    
[17] compiler_4.3.1      stringr_1.5.1       brio_1.1.4          janitor_2.2.0      
[21] getPass_0.2-4       snakecase_0.11.1    httpuv_1.6.15       htmltools_0.5.8.1  
[25] usethis_2.2.3       yaml_2.3.8          crayon_1.5.2        pillar_1.9.0       
[29] later_1.3.2         urlchecker_1.0.1    tidyr_1.3.1         ellipsis_0.3.2     
[33] openssl_2.1.1       googlesheets4_1.1.1 cachem_1.0.8        sessioninfo_1.2.2  
[37] mime_0.12           rvest_1.0.4         tidyselect_1.2.1    digest_0.6.35      
[41] stringi_1.8.3       dplyr_1.1.4         purrr_1.0.2         rprojroot_2.0.4    
[45] fastmap_1.1.1       cli_3.6.2           magrittr_2.0.3      pkgbuild_1.4.4     
[49] utf8_1.2.4          withr_3.0.0         rappdirs_0.3.3      promises_1.3.0     
[53] lubridate_1.9.3     googledrive_2.1.1   timechange_0.3.0    httr_1.4.7         
[57] gitcreds_0.1.2      cellranger_1.1.0    askpass_1.2.0       memoise_2.0.1      
[61] shiny_1.8.1.1       miniUI_0.1.1.1      profvis_0.3.8       rlang_1.1.3        
[65] Rcpp_1.0.12         xtable_1.8-4        glue_1.7.0          xml2_1.3.6         
[69] pkgload_1.3.4       rstudioapi_0.16.0   jsonlite_1.8.8      R6_2.5.1           
[73] fs_1.6.3