Snapshot function errors when the output itself is error
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comience en R/shiny.R alrededor de la línea 58, donde snapshotPreprocessOutput analiza el valor del snapshot. Reproduzca el problema con el ejemplo de shinytest proporcionado, incluida la salida de renderPlotly que devuelve un error, y verifique que app$getAllValues() ya no falle cuando la salida del snapshot no sea JSON válido.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- r
- Área
- data-visualization, testing
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100