Sending a PUT request over endpoint /api/v1/timeslots/{pk}/ results in an error 500
I'm currently migrating the timeslots of our old backend at Radio Orange to Steering. I've already created the schedules and now I'm trying to add the meta infos like memos, notes, playlists, etc.. As timeslots have already been created with the schedules I tried to update then in a PUT request, using the /api/v1/timeslots/{pk}/
. I've checked the data I'm sending and it seems to be valid. So, here's a test request over httpie
that reproduces the error on my machine:
http -f PUT http://desktop10.orange.local/steering/api/v1/timeslots/102927/ \
'Authorization:Bearer $access_token' \
cba_id=null \
end=2021-11-15T07:05:00 \
is_repetion=true \
memo='no memo given' \
playlist_id=0 \
schedule=66514 \
show=7 \
start=2021-11-15T07:00:00
HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Content-Type: text/html
Date: Fri, 11 Nov 2022 14:48:56 GMT
Server: nginx/1.22.1
Transfer-Encoding: chunked
Vary: Origin
<!doctype html>
<html lang="en">
<head>
<title>Server Error (500)</title>
</head>
<body>
<h1>Server Error (500)</h1><p></p>
</body>
</html>
Inspecting the Steering logs with docker-compose logs -f --tail=100 steering
shows me something like this:
steering | ERROR:django.request:Internal Server Error: /api/v1/timeslots/102927/
steering | Traceback (most recent call last):
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
steering | response = get_response(request)
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
steering | response = wrapped_callback(request, *callback_args, **callback_kwargs)
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
steering | return view_func(*args, **kwargs)
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/rest_framework/viewsets.py", line 125, in view
steering | return self.dispatch(request, *args, **kwargs)
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 509, in dispatch
steering | response = self.handle_exception(exc)
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 469, in handle_exception
steering | self.raise_uncaught_exception(exc)
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
steering | raise exc
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/rest_framework/views.py", line 506, in dispatch
steering | response = handler(request, *args, **kwargs)
steering | File "/steering/program/views.py", line 609, in update
steering | ts = TimeSlot.objects.filter(show=show_pk, start__gt=timeslot.start)[0]
steering | File "/root/.cache/pypoetry/virtualenvs/steering-UWcQ_v2w-py3.10/lib/python3.10/site-packages/django/db/models/query.py", line 318, in __getitem__
steering | return qs._result_cache[0]
steering | IndexError: list index out of range
However, sending the same request over endpoint /api/v1/shows/{show_pk}/schedules/{schedule_pk}/timeslots/{timeslot_pk}/
works as expected and returns a status_code 200
.