MarkEdmondson1234 / googleAuthR

Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
https://code.markedmondson.me/googleAuthR
Other
175 stars 54 forks source link

condition of length > 1 in `gar_auth` #184

Closed CorradoLanera closed 4 years ago

CorradoLanera commented 4 years ago

What goes wrong

In gar_auth() condition for scopes is computed by a use && that can conduct to coercion errors, ie:

Error in !is.null(scopes) && scopes != "": 'length(x) = 2 > 1' in coercion to 'logical(1)'

Steps to reproduce the problem

highlight_gar_auth_issue <- function() {

  # this will activate signals for the reported issue
  withr::local_envvar(c(`_R_CHECK_LENGTH_1_LOGIC2_` = "true"))

  # this is to avoid changes in local system
  # Note: scopes can be more than one (eg, in my system they are five)
  old_opt <- options(googleAuthR.scopes.selected = c("foo", "bar"))
  withr::defer(options(old_opt))

  googleAuthR::gar_auth()
}

highlight_gar_auth_issue()

Expected output

Not the thrown the reported error.

Actual output

Before you run your code, please run:

options(googleAuthR.verbose=2) and copy-paste the console output here.
Check it doesn't include any sensitive info like auth tokens or accountIds - you can usually just edit those out manually and replace with say XXX

withr::with_envvar(c(`_R_CHECK_LENGTH_1_LOGIC2_` = "true"), {
  old_opt <- options(
    googleAuthR.verbose = 2,
    googleAuthR.scopes.selected = c("foo", "bar")
  )
  withr::defer(options(old_opt))

  googleAuthR::gar_auth()
})
#> Setting deferred event(s) on global environment.
#>   * Execute (and clear) with `deferred_run()`.
#>   * Clear (without executing) with `deferred_clear()`.
#> Error in !is.null(scopes) && scopes != "": 'length(x) = 2 > 1' in coercion to 'logical(1)'

Session Info

Please run sessionInfo() so we can check what versions of packages you have installed

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Debian GNU/Linux 10 (buster)
#>  system   x86_64, linux-gnu           
#>  ui       X11                         
#>  language en_US                       
#>  collate  en_IE.UTF-8                 
#>  ctype    en_IE.UTF-8                 
#>  tz       Europe/Rome                 
#>  date     2020-07-01                  
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date       lib source                           
#>  assertthat    0.2.1      2019-03-21 [1] CRAN (R 4.0.0)                   
#>  backports     1.1.8      2020-06-17 [1] CRAN (R 4.0.1)                   
#>  cli           2.0.2      2020-02-28 [1] CRAN (R 4.0.0)                   
#>  crayon        1.3.4      2017-09-16 [1] CRAN (R 4.0.0)                   
#>  digest        0.6.25     2020-02-23 [1] CRAN (R 4.0.0)                   
#>  ellipsis      0.3.1      2020-05-15 [1] CRAN (R 4.0.0)                   
#>  evaluate      0.14       2019-05-28 [1] CRAN (R 4.0.0)                   
#>  fansi         0.4.1      2020-01-08 [1] CRAN (R 4.0.0)                   
#>  fs            1.4.1      2020-04-04 [1] CRAN (R 4.0.0)                   
#>  gargle        0.5.0      2020-05-06 [1] CRAN (R 4.0.0)                   
#>  glue          1.4.1      2020-05-13 [1] CRAN (R 4.0.0)                   
#>  googleAuthR   1.3.0      2020-06-16 [1] CRAN (R 4.0.1)                   
#>  highr         0.8        2019-03-20 [1] CRAN (R 4.0.0)                   
#>  htmltools     0.5.0      2020-06-16 [1] CRAN (R 4.0.1)                   
#>  httr          1.4.1      2019-08-05 [1] CRAN (R 4.0.1)                   
#>  jsonlite      1.6.1      2020-02-02 [1] CRAN (R 4.0.0)                   
#>  knitr         1.29       2020-06-23 [1] CRAN (R 4.0.2)                   
#>  lifecycle     0.2.0      2020-03-06 [1] CRAN (R 4.0.0)                   
#>  magrittr      1.5        2014-11-22 [1] CRAN (R 4.0.0)                   
#>  memoise       1.1.0      2017-04-21 [1] CRAN (R 4.0.0)                   
#>  pillar        1.4.4      2020-05-05 [1] CRAN (R 4.0.0)                   
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.0.0)                   
#>  purrr         0.3.4      2020-04-17 [1] CRAN (R 4.0.0)                   
#>  R6            2.4.1      2019-11-12 [1] CRAN (R 4.0.0)                   
#>  reprex        0.3.0.9001 2020-05-29 [1] Github (tidyverse/reprex@d898823)
#>  rlang         0.4.6      2020-05-02 [1] CRAN (R 4.0.0)                   
#>  rmarkdown     2.3        2020-06-18 [1] CRAN (R 4.0.1)                   
#>  rstudioapi    0.11       2020-02-07 [1] CRAN (R 4.0.0)                   
#>  sessioninfo   1.1.1      2018-11-05 [1] CRAN (R 4.0.0)                   
#>  stringi       1.4.6      2020-02-17 [1] CRAN (R 4.0.0)                   
#>  stringr       1.4.0      2019-02-10 [1] CRAN (R 4.0.0)                   
#>  styler        1.3.2      2020-02-23 [1] CRAN (R 4.0.0)                   
#>  tibble        3.0.1      2020-04-20 [1] CRAN (R 4.0.0)                   
#>  vctrs         0.3.1.9000 2020-06-19 [1] Github (r-lib/vctrs@236468a)     
#>  withr         2.2.0      2020-04-20 [1] CRAN (R 4.0.0)                   
#>  xfun          0.15       2020-06-21 [1] CRAN (R 4.0.2)                   
#>  yaml          2.2.1      2020-02-01 [1] CRAN (R 4.0.0)                   
#> 
#> [1] /home/corrado/R/x86_64-pc-linux-gnu-library/4.0
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library