rstudio/plumber

POST bodies that can't be parsed should return HTTP 415 Unsupported Media Type

オープン

#767 opened on 2021/02/08

 (5 件のコメント) (2 件のリアクション) (0 人の担当者)R (257 件のフォーク)batch import
effort: lowhelp wantedtheme: postBody

Repository metrics

Stars
 (1,437 個のスター)
PR merge metrics
 (30d に merged PR はありません)

説明

At present, if you decorate a POST endpoint with a parser (e.g. @parser json), and the client does not send you JSON data, you'll just see a message in the console and the endpoint handler will run anyway (even though, presumably, it will fail).

I don't think this is a particularly good way to surface errors to either the client or the operator -- even with the server logs, one can't use a generic message to track down which request had the problem.

Since this is a client error, the client should get a HTTP 4xx response. It turns out there is an existing HTTP status code for exactly this situation: 415 Unsupported Media Type. I'd like to see this returned instead. And, as with #757, I'd ideally like the response body/headers to be controllable.

コントリビューターガイド