plotly / plotly/plotly.R

Snapshot function errors when the output itself is error

オープン
#1,685 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

Plotly uses snapshotPreprocessOutput to remove any output values that are randomly generated. This is great.

However, if the render function outputs an error, the result is not a valid JSON. Because of this, the snapshotPreprocessOutput function errors out and frameworks like shinytest error out as well.

Example code:

library(plotly)
ui <- fluidPage(
  checkboxInput("go", label="Render plot"),
  plotlyOutput("plot")
)
server <- function(input, output, session) {
  output$plot_plotly <- renderPlotly({
    shiny::req(input$go) #induce a silent.error if input$go is FALSE
    ggplot(data.frame(x=rnorm(1000))) + 
      geom_histogram(aes(x=x))
  })
}
shinyApp(ui=ui, server=server)

Test code:

library(shinytest)
app <- ShinyDriver$new(path="tmp/")
app$getAllValues()

app$getAllValues() reports an error, because fetching the snapshot URL reports an error 500.

The issue can be easily solved in
https://github.com/ropensci/plotly/blob/bcae42bbeea8d8368fb3ca881243e6acd0c661b4/R/shiny.R#L58
I suggest you check if value is a character string before parsing as JSON.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

R/shiny.R の58行目付近から始めます。ここでは snapshotPreprocessOutput が snapshot の値を解析しています。提供された shinytest の例を使って問題を再現し、エラーを返す renderPlotly の出力も含めて、snapshot の出力が有効な JSON でない場合でも app$getAllValues() が失敗しなくなったことを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
r
領域
data-visualization, testing
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。