Fix chapter validation in video_chapters view

Update the check for 'chapters' in the request body to distinguish between missing and empty arrays, ensuring proper error handling when the 'chapters' key is absent.
This commit is contained in:
Yiannis Christodoulou 2025-10-19 12:42:39 +03:00
parent 03872d0b25
commit 08ba5ff74c

View File

@ -258,7 +258,7 @@ def video_chapters(request, friendly_token):
try: try:
request_data = json.loads(request.body) request_data = json.loads(request.body)
data = request_data.get("chapters") data = request_data.get("chapters")
if not data: if data is None:
return JsonResponse({'success': False, 'error': 'Request must contain "chapters" array'}, status=400) return JsonResponse({'success': False, 'error': 'Request must contain "chapters" array'}, status=400)
chapters = [] chapters = []