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
Preserve exception messages for wrapped Django exceptions #8051
Preserve exception messages for wrapped Django exceptions #8051
Conversation
It looks like there's a test case that'd need updating...
|
Indeed, but what would the desired behavior be? If I understand it correctly that test shows that the response data of a request contains some Python objects (as opposed to pure json)... perhaps because of mocking at some level? |
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.
I just ran into this issue as well and had to add similar code to my own exception handler that runs and then calls the drf_exception_handler. However it is missing a unit test.
Without this code the resulting detail is "Not Found." but with this code it is whatever got put into the Http404 (usually from get_object_or_404, such as "No matches the given query." - therefore testing to make sure the resulting message for the exception is not "Not Found." would be an acceptable unit test.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Reading the discussion above it appears to me that the staleness is caused by a lack of response from @tomchristie on my question on how to proceed. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I've updated the failing test to be succeeding; this at least amounts to having an implicit test on the newly introduced behavior as more or less suggested by @jeking3 |
As I understand now: no. |
@tomchristie anything I could do to move this forward? |
Stalebot go away
…On Mon, Apr 18, 2022, 13:57 stale[bot] ***@***.***> wrote:
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
—
Reply to this email directly, view it on GitHub
<#8051 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABWUWOQAB7JV37M4CDRPBLVFVL3BANCNFSM47FHYKKQ>
.
You are receiving this because you authored the thread.[image: Web Bug
from
https://github.com/notifications/beacon/AABWUWKBJDCZGACBCAL63WDVFVL3BA5CNFSM47FHYKK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOIGS5MAY.gif]Message
ID: ***@***.***>
[ { ***@***.***": "http://schema.org", ***@***.***": "EmailMessage",
"potentialAction": { ***@***.***": "ViewAction", "target": "
#8051 (comment)",
"url": "
#8051 (comment)",
"name": "View Pull Request" }, "description": "View this Pull Request on
GitHub", "publisher": { ***@***.***": "Organization", "name": "GitHub", "url": "
https://github.com" } } ]
|
Okay, yup this seems reasonable. 👍 |
DRF verson 3.15 adds more descriptive not found messages. encode/django-rest-framework#8051
DRF verson 3.15 adds more descriptive not found messages. encode/django-rest-framework#8051
djangorestframework released version 3.15.0, which includes modifications of details upon returning 404 errors (encode/django-rest-framework#8051). This commit changes the expected details of 404 responses in our tests, to match 3.15.0.
djangorestframework released version 3.15.0, which includes modifications of details upon returning 404 errors (see related issue encode/django-rest-framework#8051). This commit changes the expected details of 404 responses in our tests, to match DRF 3.15.0.
djangorestframework released version 3.15.0, which includes modifications of details upon returning 404 errors (see related issue encode/django-rest-framework#8051). This commit changes the expected details of 404 responses in our tests, to match DRF 3.15.0.
DRF now passes through Django exception details. Doubtful whether we should be testing this. See: encode/django-rest-framework#8051
I did not review your contributing guidelines, nor did I test anything using the automated tests. I also did only the most minimal of non-automated testing. Still, I thought I'd leave this here, as it may be useful to others. See it as an "issue description with PoC of a solution" if you will.
The problem: when raising standard Django exceptions
Http404
orPermissionDenied
, the error messages of these exceptions do not show up in the DRF's response. This is because these exceptions are recreated in the piece of code that this PR adapts.In this PR this is solved by making sure the recreated exceptions are recreated with the same arguments as the original versions. Whether the signatures actually match up, I did not check properly.