Closed
Description
Description of the Bug Report
When requesting an API endpoint with the include
query param, specifying an unsupported value results in an uncaught exception and traceback (below). Note: this only seems to happen when querying using the browseable API. When I use Insomnia, I get a 400 response as I'd expect.
Versions:
- Python: 3.6.15
- Django: 3.1.8
- DRF: 3.12.4
- DRF-JA: 3.1.0
Stack trace (browseable API)
Traceback (most recent call last):
File "/opt/python/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/opt/python/django/core/handlers/base.py", line 204, in _get_response
response = response.render()
File "/opt/python/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/opt/python/rest_framework/response.py", line 70, in rendered_content
ret = renderer.render(self.data, accepted_media_type, context)
File "/opt/python/rest_framework/renderers.py", line 724, in render
context = self.get_context(data, accepted_media_type, renderer_context)
File "/opt/python/rest_framework/renderers.py", line 655, in get_context
raw_data_post_form = self.get_raw_data_form(data, view, 'POST', request)
File "/opt/python/rest_framework/renderers.py", line 554, in get_raw_data_form
serializer = view.get_serializer()
File "/opt/python/rest_framework/generics.py", line 110, in get_serializer
return serializer_class(*args, **kwargs)
File "/opt/python/rest_framework_json_api/serializers.py", line 113, in __init__
validate_path(this_serializer_class, included_field_path, included_field_name)
File "/opt/python/rest_framework_json_api/serializers.py", line 99, in validate_path
path
400 response (Insomnia)
{
"errors": [
{
"detail": "This endpoint does not support the include parameter for path foo",
"status": "400",
"source": {
"pointer": "/data"
},
"code": "parse_error"
}
],
"meta": {
"version": "unversioned"
}
}
Checklist
- Certain that this is a bug (if unsure or you have a question use discussions instead)
- Code snippet or unit test added to reproduce bug
- Should be reproducible in any minimal app with no include serializers configured