[PATCH 0/4] Add 'Event.payload' field

Daniel Axtens dja at axtens.net
Mon Apr 2 17:10:44 AEST 2018


Hi Stephen,

I tried applying this and migrating, and I'm getting the following
exception trying to list events:

web_1  | Traceback (most recent call last):
web_1  |   File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/exception.py", line 41, in inner
web_1  |     response = get_response(request)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 187, in _get_response
web_1  |     response = self.process_exception_by_middleware(e, request)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/django/core/handlers/base.py", line 185, in _get_response
web_1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
web_1  |     return view_func(*args, **kwargs)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/django/views/generic/base.py", line 68, in view
web_1  |     return self.dispatch(request, *args, **kwargs)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 489, in dispatch
web_1  |     response = self.handle_exception(exc)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 449, in handle_exception
web_1  |     self.raise_uncaught_exception(exc)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/views.py", line 486, in dispatch
web_1  |     response = handler(request, *args, **kwargs)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/generics.py", line 201, in get
web_1  |     return self.list(request, *args, **kwargs)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/mixins.py", line 45, in list
web_1  |     return self.get_paginated_response(serializer.data)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 739, in data
web_1  |     ret = super(ListSerializer, self).data
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 263, in data
web_1  |     self._data = self.to_representation(self.instance)
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 657, in to_representation
web_1  |     self.child.to_representation(item) for item in iterable
web_1  |   File "/usr/local/lib/python3.6/dist-packages/rest_framework/serializers.py", line 657, in <listcomp>
web_1  |     self.child.to_representation(item) for item in iterable
web_1  |   File "/home/patchwork/patchwork/patchwork/api/event.py", line 75, in to_representation
web_1  |     if not payload.get(field):
web_1  | AttributeError: 'str' object has no attribute 'get'
web_1  | "GET /api/events/ HTTP/1.1" 500 158617

It seems that data['payload'] is a string - is that supposed to be the
case? It looks like the migrated data is in order, here's data:

web_1  | OrderedDict([('id', 317126), ('category', 'series-completed'), ('project', OrderedDict([('id', 2), ('url', 'http://localhost:8000/api/projects/2/'), ('name', 'Kernel Team'), ('link_name', 'kernel-team'), ('list_id', 'kernel-team.lists.ubuntu.com'), ('list_email', 'kernel-team at lists.ubuntu.com'), ('web_url', ''), ('scm_url', ''), ('webscm_url', '')])), ('date', '2018-03-08T12:07:19.184178'), ('payload', '{"series": {"id": 55063, "url": null, "date": "2017-08-29T23:18:10", "name": "[1/2,Artful] clocksource/drivers/arm_arch_timer: Fix mem frame loop initialization", "version": 1, "mbox": null}}')])

Looking at that in the database looks fine too:

patchwork=# select * from patchwork_event where id = 317126;
   id   |     category     |             date              | cover_id | patch_id | project_id | series_id |                                                                                                       payload     
                                                                                                  
--------+------------------+-------------------------------+----------+----------+------------+-----------+-------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
 317126 | series-completed | 2018-03-08 01:07:19.184178+00 |          |          |          2 |     55063 | "{\"series\": {\"id\": 55063, \"url\": null, \"date\": \"2017-08-29T23:18:10\", \"name\": \"[1/2,Artful] clocksour
ce/drivers/arm_arch_timer: Fix mem frame loop initialization\", \"version\": 1, \"mbox\": null}}"
(1 row)

I had to do a merge migration so it's somewhat possible that went wrong,
but it all looks in order to me. Any ideas?

Regards,
Daniel


More information about the Patchwork mailing list