LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.28k stars 885 forks source link

Add error messages that tell you which field is incorrect to the API. Proposed: Problem Details #3983

Open RonSijm opened 1 year ago

RonSijm commented 1 year ago

Requirements

Is your proposal related to a problem?

I'm using a client to consume the API, and it's difficult to understand what data is incorrect

For example:

These are just 2 examples of course, I would propose to respond with better details of everything could go wrong

Describe the solution you'd like.

Have a look at:

Describe alternatives you've considered.

Responses like Json deserialize error: invalid type: floating point '123.123', expected i32 at line 1 column 139 as plain text are even more difficult to understand. As a quickfix there should be a global error handler that wraps unexpected errors into json

Nutomic commented 1 year ago

This is a problem in actix-web, upstream issue here: https://github.com/actix/actix-web/issues/1684

There is also an open pull request but its unfinished since two years: https://github.com/actix/actix-web/pull/2376