Attribute Errors raised in Parser Silently Ignored #9426
-
Hello. First, thank you for the hard work on DRF. It has been great workin with it. There seems to be an issue where an I encountered this because I wrote the server and tested using Python 3.11, and another developer attempted to test using 3.10. My custom parser used a function that was not available in Python 3.10 (hashlib.file_digest), which caused an EnvironmentOS: Darwin 23.4.0 Darwin Kernel Version 23.4.0 x86_64 Expected Behavior500 Internal server error response and traceback in server logs. Actual Behavior200 response and no errors in server logs. $ curl --json '{"foo": "bar"}' http://localhost:8000/foos/
{}
Code to Reproducefrom rest_framework import viewsets, response, parsers, routers
class BrokenParser(parsers.JSONParser):
def parse(self, stream, media_type=None, parser_context=None):
raise AttributeError
class TestViewSet(viewsets.ViewSet):
parser_classes = (BrokenParser,)
def create(self, request, **kwargs):
return response.Response(request.data)
router = routers.DefaultRouter()
router.register("foos", TestViewSet, "foo")
urlpatterns = router.urls InvestigationThis appears to be happening because accessing the This error then raises up and causes the attribute access to fallback to the In the end, an empty response is returned and the error is silently ignored. Noob question, but why does |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
As this hasn't really gotten any attention from the maintainers, I have created an issue (#9433) regarding this bug. Since the issue was created, two PRs have been opened to attempt to resolve it. #9453 was opened by a DRF contributor and #9455 was opened by myself. I'm going to go ahead and just say this is a confirmed bug at this point. As for my final question:
This appears to have been done to recreate the original |
Beta Was this translation helpful? Give feedback.
As this hasn't really gotten any attention from the maintainers, I have created an issue (#9433) regarding this bug. Since the issue was created, two PRs have been opened to attempt to resolve it. #9453 was opened by a DRF contributor and #9455 was opened by myself. I'm going to go ahead and just say this is a confirmed bug at this point.
As for my final question:
This appears to have been done to recreate the orig…