Skip to content

Documentation fails to load/generate with filter #988

Open

Description

@alethor

System details

Output of sessioninfo::session_info()():

sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.0 (2022-04-22 ucrt)
 os       Windows 10 x64 (build 22631)
 system   x86_64, mingw32
 ui       RStudio
 language (EN)
 collate  English_Sweden.utf8
 ctype    English_Sweden.utf8
 tz       Europe/Berlin
 date     2025-02-24
 rstudio  2023.12.1+402 Ocean Storm (desktop)
 pandoc   NA

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 cachem        1.1.0   2024-05-16 [1] CRAN (R 4.2.0)
 cli           3.6.2   2023-12-11 [1] CRAN (R 4.2.3)
 crayon        1.5.2   2022-09-29 [1] CRAN (R 4.2.3)
 devtools    * 2.4.5   2022-10-11 [1] CRAN (R 4.2.0)
 digest        0.6.33  2023-07-07 [1] CRAN (R 4.2.3)
 ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.2.3)
 fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.2.0)
 fs            1.6.3   2023-07-20 [1] CRAN (R 4.2.3)
 glue          1.7.0   2024-01-09 [1] CRAN (R 4.2.3)
 htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.2.3)
 htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.2.3)
 httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.2.3)
 jsonlite      1.8.8   2023-12-04 [1] CRAN (R 4.2.3)
 later         1.3.1   2023-05-02 [1] CRAN (R 4.2.3)
 lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.2.3)
 magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.2.3)
 memoise       2.0.1   2021-11-26 [1] CRAN (R 4.2.3)
 mime          0.12    2021-09-28 [1] CRAN (R 4.2.0)
 miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.2.3)
 pkgbuild      1.4.4   2024-03-17 [1] CRAN (R 4.2.3)
 pkgload       1.3.4   2024-01-16 [1] CRAN (R 4.2.3)
 plumber       1.3.0   2025-02-19 [1] CRAN (R 4.2.0)
 profvis       0.3.8   2023-05-02 [1] CRAN (R 4.2.3)
 promises      1.2.1   2023-08-10 [1] CRAN (R 4.2.3)
 purrr         1.0.2   2023-08-10 [1] CRAN (R 4.2.3)
 R6            2.5.1   2021-08-19 [1] CRAN (R 4.2.3)
 Rcpp          1.0.12  2024-01-09 [1] CRAN (R 4.2.3)
 remotes       2.5.0   2024-03-17 [1] CRAN (R 4.2.3)
 rlang         1.1.3   2024-01-10 [1] CRAN (R 4.2.3)
 rsconnect     1.3.3   2024-11-19 [1] CRAN (R 4.2.0)
 rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.2.3)
 sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.2.3)
 shiny         1.9.1   2024-08-01 [1] CRAN (R 4.2.0)
 stringi       1.7.12  2023-01-11 [1] CRAN (R 4.2.2)
 stringr       1.5.1   2023-11-14 [1] CRAN (R 4.2.3)
 swagger       5.17.14 2024-06-11 [1] CRAN (R 4.2.0)
 urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.2.3)
 usethis     * 2.2.3   2024-02-19 [1] CRAN (R 4.2.3)
 vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.2.3)
 webutils      1.2.0   2023-11-24 [1] CRAN (R 4.2.3)
 xtable        1.8-4   2019-04-21 [1] CRAN (R 4.2.3)

 [1] C:/Users/alethor/AppData/Local/R/win-library/4.2
 [2] C:/Program Files/R/R-4.2.0/library

Example application or steps to reproduce the problem

#* @get hello_world
hello_world <- function() {
  return("Hello World!")
}

#* @filter checkAuth
function(req, res){
  if (is.null(req$username) & !req$PATH_INFO %in% c("/__docs__/", "/__swagger__/", "/openapi.json")){
    res$status <- 401 # Unauthorized
    return(list(error="Authentication required"))
  } else {
    plumber::forward()
  }
}

Describe the problem in detail

When the filter in the above function is active /docs/ fails to generate and/or load. However, commenting this filter, running the code once and then uncommenting the filter and rerunning does show docs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions