Skip to content

preempt arguments cause error with match() #998

@JosiahParry

Description

@JosiahParry

Using the preempt function with a plumber handler does not work. See this basic reprex:

library(plumber)
pr() |> 
  pr_get(
    "/hi",
    function() "hello world",
    preempt = function(req, res) {}
  )
#> Error in match(x, table, nomatch = 0L): 'match' requires vector arguments

sessionInfo()
#> R version 4.5.0 alpha (2025-03-25 r88054)
#> Platform: aarch64-apple-darwin20
#> Running under: macOS Sequoia 15.0.1
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib 
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
#> 
#> 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/Los_Angeles
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] plumber_1.3.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.37     later_1.4.1       R6_2.6.1          fastmap_1.2.0    
#>  [5] swagger_5.17.14.1 xfun_0.51         magrittr_2.0.3    webutils_1.2.2   
#>  [9] glue_1.8.0        knitr_1.49        htmltools_0.5.8.1 rmarkdown_2.29   
#> [13] lifecycle_1.0.4   promises_1.3.2    cli_3.6.4         reprex_2.1.1     
#> [17] withr_3.0.2       compiler_4.5.0    tools_4.5.0       evaluate_1.0.3   
#> [21] Rcpp_1.0.14       yaml_2.3.10       jsonlite_1.9.0    crayon_1.5.3     
#> [25] rlang_1.1.5       fs_1.6.5          stringi_1.8.4

Created on 2025-04-17 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions