ffverse / ffscrapr

R API Client for Fantasy Football League Platforms
https://ffscrapr.ffverse.com
Other
84 stars 21 forks source link

sleeper_userleagues: Error in `dplyr::rename() #429

Open soricinae opened 3 months ago

soricinae commented 3 months ago

Describe the bug sleeper_userleagues doesn't handle some case and throws an Error instead of returning a valid result (e.g. empty collection).

Reprex

> sleeper_userleagues("sssskoch", 2021)
Error in `dplyr::rename()`:
! Can't rename columns that don't exist. 
x Column `name` doesn't exist.
 # Please include the code used for the connection object from `ff_connect()`

N/A, no connection needed for sleeper_userleagues

Expected behavior Maybe it should return an empty collection

Session information Please copy the output of ffscrapr::ffverse_sitrep() into the box below.

N/A, this command hangs.

tanho63 commented 3 months ago

Please reinstall from dev and try again / report back

install.packages("ffscrapr", repos = c("https://ffverse.r-universe.dev", getOption("repos")))
soricinae commented 3 months ago

It did not fix it: Script run in a new interactive window:

install.packages("ffscrapr", repos = c("https://ffverse.r-universe.dev", getOption("repos")))
library(ffscrapr)
sleeper_userleagues("sssskoch", 2021)

Output:

  There is a binary version available but the source version is later:
         binary   source needs_compilation
ffscrapr  1.4.8 1.4.8.18             FALSE

installing the source package 'ffscrapr'

trying URL 'https://ffverse.r-universe.dev/src/contrib/ffscrapr_1.4.8.18.tar.gz'
Content type 'application/x-gzip' length 363240 bytes (354 KB)
downloaded 354 KB

* installing *source* package 'ffscrapr' ...

...

The downloaded source packages are in
        'C:\Users\foo\AppData\Local\Temp\RtmpAJDhnI\downloaded_packages'
Error in `dplyr::rename()`:
! Can't rename columns that don't exist.
x Column `name` doesn't exist.
Run `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/vctrs_error_subscript_oob>
Error in `dplyr::rename()`:
! Can't rename columns that don't exist.
x Column `name` doesn't exist.
---
Backtrace:
     x
  1. +-base::source(...)
  2. | +-base::withVisible(eval(ei, envir))
  3. | \-base::eval(ei, envir)
  4. |   \-base::eval(ei, envir)
  5. +-ffscrapr::sleeper_userleagues("sssskoch", 2021) at c:\Users\foo\blah\scratch\test-sleeper-league-bug.r:3:0
  6. | +-ffscrapr:::ff_userleagues.sleeper_conn(...)     
  7. | | +-base::withVisible(eval(mc, parent.frame()))   
  8. | | \-base::eval(mc, parent.frame())
  9. | |   \-base::eval(mc, parent.frame())
 10. | \-ffscrapr (local) `<fn>`(user_name = user_name, season = season)
 11. |   \-... %>% ...
 12. +-dplyr::mutate(...)
 13. +-dplyr::rename(., league_name = "name")
 14. \-dplyr:::rename.data.frame(., league_name = "name")
Run rlang::last_trace(drop = FALSE) to see 19 hidden frames.

ffverse_sitrep() output (I wasn't waiting long enough)

> ffverse_sitrep()
-- System Info ------------------------------------------
* R version 4.1.1 (2021-08-10) * Running under: Windows 10 x64 (build 22621)
-- Package Status ---------------------------------------
   package installed  cran      dev behind
1 ffscrapr  1.4.8.18 1.4.8 1.4.8.18
-- Package Options --------------------------------------
* No options set for above packages
* generics      (0.1.3)   * withr        (3.0.0)   * Rcpp          (1.0.7)
* glue          (1.6.2)   * cachem       (1.0.6)   * RcppParallel  (5.1.4)
* httr          (1.4.7)   * cli          (3.1.0)   * rlang         (0.4.11)
* jsonlite      (1.8.4)   * cpp11        (0.4.1)   * stats         (4.1.1)
* lifecycle     (1.0.4)   * crayon       (1.4.2)   * stringfish    (0.15.3)
* magrittr      (2.0.3)   * curl         (4.3.2)   * stringi       (1.7.5)
* memoise       (2.0.1)   * data.table   (1.14.2)  * stringr       (1.4.0)
* mime          (0.12)    * dplyr        (1.0.7)   * tibble        (3.1.5)
* nflreadr      (1.4.0)   * ellipsis     (0.3.2)   * tidyr         (1.1.4)
* openssl       (2.0.6)   * fansi        (0.5.0)   * tidyselect    (1.1.1)
* pillar        (1.9.0)   * fastmap      (1.1.0)   * tools         (4.1.1)
* purrr         (1.0.1)   * generics     (0.1.1)   * utf8          (1.2.2)
* qs            (0.25.5)  * glue         (1.4.2)   * utils         (4.1.1)
* R6            (2.5.1)   * graphics     (4.1.1)   * vctrs         (0.3.8)
* RApiSerialize (0.1.2)   * grDevices    (4.1.1)
-- Not Installed ----------------------------------------* ffsimulator  * ffpros  * ffopportunity
--------------------------------------------------------->