middleware
middleware copied to clipboard
Return Flask errors as JSON instead of HTML (mentioned in issue #561)
Linked Issue(s) https://github.com/middlewarehq/middleware/issues/561
Acceptance Criteria fulfillment
Changed app.py to change such that flash returns errors as JSON instead.
Further comments
May want to check to see if it works, I was having trouble running some of the program.
Hey @dominicghizzoni, thank you so much for your PR. We will however need you to go ahead and sign the CLA shared by the bot in the comment above. Thanks! :)
Please also update the PR title to reflect the nature of the change.
what must i change to pass all the checks
what must i change to pass all the checks
Hey @dominicghizzoni Please read Contributions Guide It will help you.
@samad-yar-khan the point I was trying to convey was errors like 404(all errors less than 500) should be handled in the business logic itself right? There won't more than 2-3 error possibility for any endpoint. I can observe that most of the api view are already checking for errors and returning the json error as well.
For the 404 page not found related to false routes or redirections, should be handled with the frontend routing.
So imo there will be some endpoints where something unexpected will occur, and for that flask returns with a html error file. So can't show that file in front end where we are expecting a simple object/string. To avoid this we want to respond with a json. For debugging concerns these error can be logged to db or something like we can leverage certains tools like Sentry. But the error that is return as json should be hardcoded.
Please let me know if I am misunderstanding it, my knowledge is very limited after all.
Hey @dominicghizzoni, are you considering continuing this PR?
Hey @dominicghizzoni, are you considering continuing this PR?
Someone else in the issue thread said they would try to complete it
Closing this PR then. :)