eyp-developers / statistics

The platform to measure European Youth Parliament debates
https://stats.eyp.org
GNU General Public License v3.0
9 stars 2 forks source link

accessing a debate page of a session, which has not set the active debate, generates an internal server error #135

Closed wolfskaempf closed 6 years ago

wolfskaempf commented 7 years ago
[28/Dec/2016 02:03:23] "GET /api/session/16/vote/15/?_=1482886977789 HTTP/1.1" 200 328
Internal Server Error: /api/active_debate/16/
Traceback (most recent call last):
  File "/Users/tom/GitHub/statistics/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/tom/GitHub/statistics/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/tom/GitHub/statistics/statistics/views/apis.py", line 93, in active_debate_api
    active_committee = Committee.objects.filter(session=session).filter(committee_name=active_debate.active_debate)[0]
  File "/Users/tom/GitHub/statistics/lib/python2.7/site-packages/django/db/models/query.py", line 297, in __getitem__
    return list(qs)[0]
IndexError: list index out of range
wolfskaempf commented 7 years ago

Can be reproduced by creating a new session with at least one committee and visiting the debate page of that committee. The part of the code which checks if the active debate has changes will call /api/active_debate/16/ every three seconds to see if it has changed.

ostenbom commented 6 years ago

Might be fixed in new branch