Snapshot function errors when the output itself is error
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- R
- Estrelas
- 2.7k
- Forks
- 641
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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.
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece em R/shiny.R, por volta da linha 58, onde snapshotPreprocessOutput analisa o valor do snapshot. Reproduza o problema com o exemplo de shinytest fornecido, incluindo a saída de renderPlotly que retorna um erro, e verifique se app$getAllValues() não falha mais quando a saída do snapshot não é um JSON válido.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- r
- Domínio
- data-visualization, testing
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 45/100