fractal-analytics-platform / fractal-web

Web client for Fractal
https://fractal-analytics-platform.github.io/fractal-web/
BSD 3-Clause "New" or "Revised" License
6 stars 0 forks source link

Improve formatting of 422 Pydantic validation errors #311

Closed tcompa closed 1 week ago

tcompa commented 11 months ago

They are very nested by default, but the relevant information can be displayed in a simpler way - see https://github.com/fractal-analytics-platform/fractal-web/pull/310#issuecomment-1754739886 and https://github.com/fractal-analytics-platform/fractal-client/issues/548#issuecomment-1733382438.

https://github.com/fractal-analytics-platform/fractal-web/pull/310/commits/af390602f1cbd894cdf3f6a768a6d59a02f205a4 introduces getSimpleValidationMessage, where we check by hand that the error structure matches with a known one. For any deviation from this given structure (e.g. because there are multiple validation errors, or because future fastapi/pydantic versions change this structure) we should always return the original message, but when there is a matching structure we can make it more readable.

tcompa commented 1 month ago

An example of what could be improved: image

An example where this is already handled: image

zonia3000 commented 1 month ago

Some explanation about error handling @ 0c473b29be6d0b86d3429e6c35c290f52bec2b7f

Errors that have been improved by the refactoring:

image

image

image

image

jluethi commented 1 month ago

That looks great! If we can move all our errors to such a display, that's a great win! :)

tcompa commented 1 week ago

This will be closed with #542. Let's open other issues in case error messages for payload fields are not clear or not well formatted.