Snapshot function errors when the output itself is error
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại R/shiny.R, khoảng dòng 58, nơi snapshotPreprocessOutput phân tích giá trị snapshot. Tái hiện sự cố bằng ví dụ shinytest được cung cấp, bao gồm cả đầu ra renderPlotly trả về lỗi, và xác minh rằng app$getAllValues() không còn thất bại khi đầu ra snapshot không phải là JSON hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- r
- Lĩnh vực
- data-visualization, testing
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100