plumber icon indicating copy to clipboard operation
plumber copied to clipboard

Docs suggest error msg returned, but it is not.

Open mmuurr opened this issue 2 years ago • 2 comments

I'm not sure if either (i) the docs are out-of-sync with the current release or (ii) the behavior is a bug. Plumb a simple API with only this endpoint, using defaults for everything else:

#* @get /simple
function() {
  stop("I'm an error!")
}

Plumbed via:

pr_run(pr("myfile.R"), host = "127.0.0.1", port = 8080)

The returned payload does not include the error msg, despite the docs suggesting it should (in the default config, at least):

curl http://localhost:8080/simple

yields:

{"error":"500 - Internal server error"}

{plumber} v1.2.1

mmuurr avatar May 31 '23 12:05 mmuurr

I'm not familiar with the history here - but I think you need to opt into messages - https://www.rplumber.io/reference/pr_set_debug.html - possibly something to do with plumber not leaking data by default.

It might be that the docs need updating...

slodge avatar Jun 14 '23 14:06 slodge

Debugging is enabled by default in interactive mode and you will get the same message as the doc. Otherwise, only the error is returned to the client.

https://github.com/rstudio/plumber/blob/72d68c6400596b7743a7fc1c9a6a976a6bc9d378/R/plumber.R#L1338

https://github.com/rstudio/plumber/blob/72d68c6400596b7743a7fc1c9a6a976a6bc9d378/R/plumber.R#L973

If you want debugging info in non-interactive mode, you can follow @slodge suggestion above.

meztez avatar Nov 20 '23 23:11 meztez