mu-semtech / mu-python-template

Template for running Python/Flask microservices
MIT License
4 stars 8 forks source link

`error` helper doesn't let you send multiple errors #16

Open sergiofenoll opened 11 months ago

sergiofenoll commented 11 months ago

The JSON:API specification states that servers may continue processing after encountering an error. In a case that we encounter multiple errors, we probably want to return multiple error objects to the client to inform them about all the different errors.

Currently the error helper doesn't allow that, as it always returns a Flask Response object which is AFAIK not meant to be further mutated, especially it's body. If a user of the template wants to send multiple errors in one response they will have to craft the response themselves.

Would it make sense to add a new helper (so as to not create a breaking change in the template) called errors that lets users create responses containing multiple errors? Alternatively the behaviour of the error helper could be changed to only generate an error object (per the JSON:API spec) and have users generate the response themselves, but this would be a breaking change.