rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more

Home Page:http://rstudio.github.io/rsconnect/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Turn off all deployment logs from deployApp

alessap opened this issue · comments

Hey,

Due to GDPR regulations and the likes, it is not allowed to show sensitive data in all the IT platforms and applications we use in our organization.
For this reason, we wish to completely turn off the logs from rsconnect::deployApp() with for example logLevel="quiet" such that potential sensitive data are not shown in the deployment on our platform. Often traceback error message spit out data used in the code, which might be sensitive data.

This seems to work correctly with knitr and R, however with quarto and python we still see the traceback from an error. We wish not to see these logs.

Best regards,
Alessandro

Is there any update regarding this issue?

Customer ticket 101818

@alessap - No updates to share at the moment, but I'll try to make time for this issue soon.

Have you considered capturing and discarding the output with capture.output()?

Given any type of content, output from the deployment task is emitted to console, even with logLevel = "quiet". This was tested with Quarto+R, Quarto+Python, and R Markdown documents having both syntax errors and other runtime errors.

---
title: "Python syntax"
---

```{python}
1 + 1 +
```
---
title: "R syntax"
---

```{r}
1 + 1 +
```
---
title: "Python error"
---

```{python}
raise Exception("whoops")
```
---
title: "R error"
---

```{r}
stop("hammer time")
```

The R syntax and error examples were deployed as qmd and Rmd (rendering with Quarto and R Markdown, respectively).

When a Quarto + Python document contains an error (any type of rendering error, including a Python syntax error), that error is included in the deployment task output and emitted to console.

Part of that output could look like:

Executing 'syntax-py.ipynb'
  Cell 1/1: ''...

An error occurred while executing the following cell:
------------------
1 + 1 +
------------------


  Cell In[1], line 1
    1 + 1 +
           ^
SyntaxError: invalid syntax


Unable to render the deployed content: Rendering exited abnormally: exit status 1

When a Quarto + R document or an R Markdown output contains a similar error, that error is also included in the deployment task output and emitted to console.

Part of that output could look like (both Quarto+R and R Markdown output is similar):

processing file: syntax-r.qmd
1/3                  
2/3 [unnamed-chunk-1]



Quitting from lines 6-7 [unnamed-chunk-1] (syntax-r.qmd)
Error in `parse()`:
! <text>:2:0: unexpected end of input
1: 1 + 1 +
   ^
Backtrace:
  1. global .main()
  2. execute(...)
  3. rmarkdown::render(...)
  4. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  5. knitr:::process_file(text, output)
     ...
 13. knitr:::eng_r(options)
 16. knitr (local) evaluate(...)
 17. evaluate::evaluate(...)
 19. evaluate:::parse_all.character(...)
 20. base::parse(text = x, srcfile = src)
Execution halted
Unable to render the deployed content: Rendering exited abnormally: exit status 1

In addition, a syntax error may also confuse renv while it is scanning for dependencies, producing output like:

WARNING: One or more problems were discovered while enumerating dependencies.

# /private/var/folders/f5/d_lvj8s17bx46zzhfr5gqywc0000gp/T/Rtmp5VZTQ2/file13527336ff1e8/syntax-r.qmd --------
Error: <text>:8:0: unexpected end of input
6: 1 + 1 +
7: 
  ^

Please see `?renv::dependencies` for more information.

When the Quarto + Python document produces an execution error, the error is included in the deployment task output and emitted to the console.

Part of this output could look like:

Executing 'error-py.ipynb'
  Cell 1/1: ''...

An error occurred while executing the following cell:
------------------
raise Exception("whoops")
------------------


---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Cell In[1], line 1
----> 1 raise Exception("whoops")

Exception: whoops

Stopped session pings to http://127.0.0.1:44537
An error occurred while running your content.
This link offers advice for this kind of error:
    https://docs.posit.co/connect/user/troubleshooting/#render-python-code-error
Unable to render the deployed content: An error occurred while running your content. (Error code: render-python-code-error)

When a Quarto + R or R Markdown document contains a similar runtime error, that error is included in the deployment task output and emitted to the console.

Part of that output could look like:

processing file: error-r.qmd
1/3                  
2/3 [unnamed-chunk-1]



Quitting from lines 6-7 [unnamed-chunk-1] (error-r.qmd)
Error:
! hammer time
Execution halted
Unable to render the deployed content: Rendering exited abnormally: exit status 1

In this case (runtime error, not a syntax error), there is no renv complaint ahead of deployment.

This testing indicates that we need two changes:

  1. suppress task output with logLevel = "quiet"
  2. suppress renv dependency errors with logLevel = "quiet"

Other than the renv warnings, there appears to be no difference in output for different types of content.