middleware icon indicating copy to clipboard operation
middleware copied to clipboard

Return Flask errors as JSON instead of HTML (mentioned in issue #561)

Open dominicghizzoni opened this issue 1 year ago • 6 comments

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.

dominicghizzoni avatar Oct 03 '24 03:10 dominicghizzoni

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 03 '24 03:10 CLAassistant

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! :)

jayantbh avatar Oct 03 '24 08:10 jayantbh

Please also update the PR title to reflect the nature of the change.

jayantbh avatar Oct 03 '24 08:10 jayantbh

what must i change to pass all the checks

dominicghizzoni avatar Oct 03 '24 19:10 dominicghizzoni

what must i change to pass all the checks

Hey @dominicghizzoni Please read Contributions Guide It will help you.

im-vipin avatar Oct 04 '24 05:10 im-vipin

@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.

thesujai avatar Oct 10 '24 15:10 thesujai

Hey @dominicghizzoni, are you considering continuing this PR?

jayantbh avatar Oct 23 '24 18:10 jayantbh

Hey @dominicghizzoni, are you considering continuing this PR?

Someone else in the issue thread said they would try to complete it

dominicghizzoni avatar Oct 23 '24 19:10 dominicghizzoni

Closing this PR then. :)

jayantbh avatar Oct 30 '24 20:10 jayantbh