`array_caster()` stack overflow when `@body` item is array of objects
評価
調査の方向性
Start in R/type_caster.R at array_caster() and reproduce the request with an @body array of objects using the payload shown. Trace the caster reassignment and verify that evaluating the handler's body parameter no longer overflows and returns the parsed items object.
索引モデルが issue の本文から書いたものです。
説明
Hi there,
Ran into an issue when building a post endpoint, which had an @body annotation for an array of objects (items:[{name:string, email:string}]) which caused a stack overflow at request time when the handler's body param is first evaluated. Removing this typing from the @body annotation allows it to run as expected.
I, with some AI assistance, believe the issue is in array_caster() in R/type_caster.R - the var caster is being reassigned to a function in the if/else statement, so at request time the enclosing environment of caster() is different than when it was created.
reprex (passing {"items": [{"name": "foo", "email": "[email protected]"}]} as body in post request):
library(plumber2)
api() |>
api_logger(
logger = logger_console(),
access_log_format = combined_log_format
) |>
api_post(
path = "/test",
handler = function(body) { body },
parsers = get_parsers("json"),
doc = openapi_operation(
request_body = openapi_request_body(
content = openapi_content(
"application/json" = openapi_schema(
x = I("object"),
properties = list(
items = list(
type = "array",
items = list(
type = "object",
properties = list(
name = list(type = "string"),
email = list(type = "string")
)
)
)
)
)
)
)
)
) -> test_api
plumber2::api_run(
api = test_api,
port = 10000,
block = TRUE,
showcase = TRUE
)
sessionInfo()
R version 4.4.3 (2025-02-28 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plumber2_0.2.0
loaded via a namespace (and not attached):
[1] xml2_1.4.0 stringi_1.8.4 magrittr_2.0.3 evaluate_1.0.3 webutils_1.2.2 jsonlite_1.9.1 sodium_1.4.0 brio_1.1.5 urltools_1.7.3.1 promises_1.5.0 purrr_1.0.4 textshaping_1.0.0 cli_3.6.4
[14] reqres_1.2.0 rlang_1.1.5 brotli_1.3.2 routr_2.0.0 triebeard_0.4.1 base64enc_0.1-3 otel_0.2.0 tools_4.4.3 jose_1.2.1 firestorm_0.1.0 nanonext_1.8.1 httpuv_1.6.15 waysign_0.1.1
[27] rapidoc_9.3.4 vctrs_0.6.5 R6_2.6.1 firesafety_0.1.0 lifecycle_1.0.4 firesale_0.1.1 stringr_1.5.1 fs_1.6.5 ragg_1.3.3 later_1.4.1 glue_1.8.0 Rcpp_1.0.14 systemfonts_1.3.2
[40] fireproof_0.1.0 xfun_0.54 fiery_1.5.0 storr_1.2.6 knitr_1.50 websocket_1.4.4 mirai_2.6.1 svglite_2.2.2 compiler_4.4.3 roxygen2_7.3.2 askpass_1.2.1 openssl_2.3.2
- 主要言語
- R
- スター
- 119
- フォーク
- 17
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
posit-dev/plumber2 のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
`except` argument in `Plumber2$add_shiny` method is not respected対応中かも @cgiachalis が 139 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
-
Development Roadmapオープン
難易度 2/5 1時間未満 初心者へのやさしさ 20/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
posit-dev/plumber2 の issue をすべて見る
似ている issue
-
num_ode_rk4_adaptive rejects atol = 0 while accepting rtol = 0 and while num_ode_dopri5 accepts bothオープンarea/ode-pde good first issue help wanted kind/contract severity/4-minor
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Apich-Organization/rssn#383 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
PRL-PRG/r-compile-server#70 · コメント 1 件 ·
-
dependencies docker enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
posit-dev/images-workbench#257 ·
メンテナーはふだん 1 日以内に返信
-
dependencies docker enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
posit-dev/images-package-manager#188 ·
メンテナーはふだん 1 日以内に返信
-
dependencies docker enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
posit-dev/images-connect#222 ·
メンテナーはふだん 1 日以内に返信