Problem
All json.loads(request.body) calls in platform/api/views/courses.py are unguarded. A malformed request body raises json.JSONDecodeError which bubbles up as a 500 response instead of a clean 400.
Affected methods:
CourseView.post
CourseContentView.post
ReorderCourseContentView.post
SingleCourseContentView.post
SingleCourseView.post
SendLessonToPlatformUser.post
Suggestion
Add a shared parse_body helper that catches json.JSONDecodeError and returns a consistent 400 error payload, then use it in all the above methods.
Problem
All
json.loads(request.body)calls inplatform/api/views/courses.pyare unguarded. A malformed request body raisesjson.JSONDecodeErrorwhich bubbles up as a 500 response instead of a clean 400.Affected methods:
CourseView.postCourseContentView.postReorderCourseContentView.postSingleCourseContentView.postSingleCourseView.postSendLessonToPlatformUser.postSuggestion
Add a shared
parse_bodyhelper that catchesjson.JSONDecodeErrorand returns a consistent 400 error payload, then use it in all the above methods.