Regression in the patches API
Ralf Ramsauer
ralf.ramsauer at oth-regensburg.de
Thu Jun 4 02:00:15 AEST 2020
Hi,
it seems that the /patches-API is broken under certain conditions. The
API call throws an exception if the following conditions are met:
- The user is logged in a browser
- In the browser, the user requests /api/patches/<someid>/
- The user is maintainer of the project related to <someid>
This fault can easily be reproduced with a vanilla patchwork instance:
1. ./manage.py createsuperuser # create 'admin' superuser
2. Login in a browser as admin
3. Create some new project
4. ./manage.py parsearchive list.mbox # import some patches
6. In the browser, navigate to /admin/auth/user/1/change
and add the user as maintainer of the project
7. In the browser, navigate to /api/patches/1
8. Exception is thrown
The exception is not thrown, if step 6 is either skipped or reverted.
Please find the backtrace attached.
Thanks
Ralf
-------------- next part --------------
web_1 | Internal Server Error: /api/patches/1/
web_1 | Traceback (most recent call last):
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
web_1 | response = get_response(request)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/core/handlers/base.py", line 145, in _get_response
web_1 | response = self.process_exception_by_middleware(e, request)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/core/handlers/base.py", line 143, in _get_response
web_1 | response = response.render()
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/response.py", line 105, in render
web_1 | self.content = self.rendered_content
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/response.py", line 70, in rendered_content
web_1 | ret = renderer.render(self.data, accepted_media_type, context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/renderers.py", line 724, in render
web_1 | context = self.get_context(data, accepted_media_type, renderer_context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/renderers.py", line 695, in get_context
web_1 | 'put_form': self.get_rendered_html_form(data, view, 'PUT', request),
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/renderers.py", line 511, in get_rendered_html_form
web_1 | return self.render_form_for_serializer(serializer)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/renderers.py", line 518, in render_form_for_serializer
web_1 | return form_renderer.render(
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/renderers.py", line 372, in render
web_1 | return template.render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render
web_1 | return self.template.render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/base.py", line 171, in render
web_1 | return self._render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/test/utils.py", line 95, in instrumented_test_render
web_1 | return self.nodelist.render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/base.py", line 936, in render
web_1 | bit = node.render_annotated(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/base.py", line 903, in render_annotated
web_1 | return self.render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/defaulttags.py", line 209, in render
web_1 | nodelist.append(node.render_annotated(context))
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/base.py", line 903, in render_annotated
web_1 | return self.render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/defaulttags.py", line 309, in render
web_1 | return nodelist.render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/base.py", line 936, in render
web_1 | bit = node.render_annotated(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/base.py", line 903, in render_annotated
web_1 | return self.render(context)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/django/template/library.py", line 192, in render
web_1 | output = self.func(*resolved_args, **resolved_kwargs)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/templatetags/rest_framework.py", line 87, in render_field
web_1 | return renderer.render_field(field, style)
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/renderers.py", line 339, in render_field
web_1 | field = field.as_form_field()
web_1 | File "/opt/pyenv/versions/3.8.2/lib/python3.8/site-packages/rest_framework/utils/serializer_helpers.py", line 122, in as_form_field
web_1 | for key, value in self.value.items():
web_1 | AttributeError: 'list' object has no attribute 'items'
web_1 | "GET /api/patches/1/ HTTP/1.1" 500 235336
More information about the Patchwork
mailing list