Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress error messages #1123

Closed
jcheng5 opened this issue Mar 2, 2016 · 2 comments
Closed

Suppress error messages #1123

jcheng5 opened this issue Mar 2, 2016 · 2 comments

Comments

@jcheng5
Copy link
Member

jcheng5 commented Mar 2, 2016

For security reasons, have an option to prevent any raw error messages from getting to the client--make them sanitized. Raw error messages can contain file paths, internal hostnames, argument values, and sometimes even source code snippets.

(Let the user throw "trusted" exceptions and turn all other exceptions into generic exceptions?)

Currently you can work around this by throwing a generic exception in options(shiny.error = function() { ... }) but that means even logging doesn't occur (you can't get the error from within shiny.error--seems perverse, but it's modeled on options(error)).

We should at least have shiny.error functions with at least one argument, be passed the error. This would allow a complete workaround.

We should also consider building our own version of this and sticking it directly into our server products, so you can opt into this behavior across an entire server (or override on a per-app basis) with a config file.

Ref: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/shiny-discuss/FyMGa2R_Mgs/FNyusgdxBgAJ

cc @benb111

@jcheng5
Copy link
Member Author

jcheng5 commented Mar 22, 2016

Places to test: downloadHandler, ui.R itself

@bborgesr
Copy link
Contributor

Closed via #1156

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Jul 28, 2016
Upstream changes:

CHANGES IN knitr VERSION 1.13

NEW FEATURES

    code chunks that generate metadata may be cached now; it requires htmlwidgets >= v0.6 and htmltools >= 0.3.3 if you cache code chunks that contain HTML widgets or Shiny inputs/outputs (#1158)

    when the output format is not HTML, HTML widgets used to fail to render; now knitr will try to generate static screenshots for HTML widgets automatically using the webshot package; you can specify alternative screenshots via the chunk option screenshot.alt (which takes a character vector of image paths), and pass more options to webshot::webshot() via the chunk option screenshot.opts, e.g. list(delay = 3, cliprect = 'viewport')

    added two functions include_url() and include_app() to embed URLs in the output (the latter is for Shiny app URLs); when the output format is HTML, iframe will be used; otherwise screenshots of the URLs will be used

    screenshotting for HTML widgets and URLs can be forced for all output formats via the chunk option screenshot.force = TRUE; if you set the chunk option screenshot.force = FALSE, knitr will just render these content normally and not take screenshots

    added a new chunk option fig.link, which can be used to attach hyperlinks on figures, e.g. you can add a link to a screenshot of a Shiny app so that readers can check out the actual live app after clicking on the static screenshot (this chunk option currently only works for Markdown and LaTeX output)

    syntactical errors in code chunks will be allowed when the chunk option error = TRUE and the package version of evaluate is at least 0.8.4; previously knitr would just stop on parsing errors (r-lib/evaluate#65)

    PNG/JPEG images included via include_graphics() also respects the chunk option dpi now; if it is numeric and the chunk option out.width is not set, the output width (in inches) of an image will be automatically calculated from the actual width (in pixels) divided by dpi; note this feature requires the packages png and/or jpeg to be installed, and you can disable the feature using dpi = NA (thanks, @hadley, rstudio/bookdown#38)

    added a new hook function named evaluate in knit_hooks so that users can redefine a evaluator to evaluate the code chunk; the default is evaluate::evaluate(), and your custom evaluator must be compatible with evaluate::evaluate() in terms of the argument names and the data structure of the returned value (a list of values with special classes)

    added a new function combine_words() to combine multiple words / phrases into a single string, which may be useful in inline R expressions, e.g. combine_words(c('a', 'b', 'c')) returns a, b, and c

    render_markdown() gained a new argument fence_char to customize the character to be used as the code blocks fence, e.g. it can be a backtick, or a tilde, depending on the Markdown rendering engine (thanks, @tinyheero, #1161)

    the pandoc() function no longer assumes Markdown input (thanks, @scls19fr, #1170)

    added a new function knit_meta_add() so that users can manually inject metadata into the current knitr session

    for the tikz engine, if fig.ext = 'svg', dvisvgm will be called to convert the DVI output of TikZ to SVG; you need to install dvisvgm, and Windows users have to install GhostScript as well (thanks, @dkilfoyle, #1177)

    new js and css engines which surround their content with <script> and <style> tags respecitvely, and print no output when not in an HTML document

    for LaTeX tables, kable() supports short captions now via the caption.short argument, e.g. kable(..., caption = 'A long caption', caption.short = 'A short caption') (thanks, @ismayc, #1199)

    added three global R options knitr.sanitize.errors, knitr.sanitize.warnings, and knitr.sanitize.messages to mask or change the messages, e.g. if options(knitr.sanitize.errors = TRUE) and the chunk option error = TRUE, the actual error message will be replaced by a character string like "An error occurred"; these options can also accept character values so you can customize the messages to be displayed, e.g. options(knitr.sanitize.warnings = 'You had a warning from the code'); see rstudio/shiny#1123 for the motivation of these options

BUG FIXES

    when the chunk option cache.rebuild = TRUE, the cache database should be rewritten (thanks, Oleg Mayba)

    include_graphics() did not work in inline R expressions (thanks, @WastlM, #1166)

    the cex parameter was not correctly restored in the case of opts_knit$set(global.par = TRUE) (http://stackoverflow.com/q/35606445/559676)

    for Rnw documents, when there are two instances of \documentclass{}, knitr might mistakenly treats the second instance as the the actual command to declare the document class (thanks, #1180, @ekstroem)

    corrected the environment for evaluating R scripts in stitch_rhtml() and stitch_rmd() (thanks, @hughan, #1207)

MAJOR CHANGES

    the default value of the package option eval.after is changed from NULL to fig.cap, i.e. the figure caption will always be evaluated after a code chunk is evaluated (thanks, @JoshOBrien, #1165)

    the function eclipse_theme() has been removed since the website eclipsecolorthemes.org has been down for a long time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants