-
Notifications
You must be signed in to change notification settings - Fork 7
Fix unhandled exceptions in API views causing 500 errors (Issue #10) #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unhandled exceptions in API views causing 500 errors (Issue #10) #73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from these, as a general practice, try to segregate different changes in meaningful independent commits (for eg, .gitignore change, settings.py change, test addition/updates, should have been separate commits)
Also, It would be nice to see fix for:
3dmr/mainapp/tests/views/test_model.py
Lines 395 to 397 in cfb15c7
| # def test_revise_non_existent_model_id(self): | |
| # response = self.client.get(reverse('revise', args=[99999999])) | |
| # self.assertEqual(response.status_code, 404) |
AyushDharDubey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from these, there are commented out pieces of code from the previous iteration which needs to be removed
f5fd142 to
cb4b308
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few tiny nit picking and then we are ready to merge.
Also, this PR has been bloated with commits along with the review iterations, would you be able to squash the commits into 2 or 3 with meaningful commit messages and force push.
|
Also, some of the tests could be extended to test the output more thoroughly. In particular, it is always good to have tests to ensure that something does not happen Originally proposed by @lonvia in #8 (review) In case you would you like to enhance the test suite further, this one would need to go in a separate PR. |
- Handle malformed JSON safely - Improve error handling in API views - Relax and reorder URL regex patterns - Update API tests for search_full
- Organize code into correct files - Remove redundant logic
- Restore mixins.py - Restore .gitignore - Stabilize branch after refactor
36883a0 to
ef5b883
Compare
Summary
This PR fixes multiple cases where API views were throwing 500 Internal Server Errors due to unhandled native Python exceptions.
These failures were previously worked around in Issue #8 using assertRaises. This change addresses the root cause by adding proper exception handling in the views and updating the test suite accordingly.
What was fixed
API View Error Handling
Files updated
mainapp/api.py
Routing Improvements
Files updated
mainapp/urls.py
Test Suite Updates
Files updated
Verification