kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Return 400 for malformed lesson, course session and attendance session writes

Open rtibbles opened this issue 2 weeks ago β€’ 7 comments

πŸ™‚ Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:

  • Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
  • Confirm that you’ve read the guidelines in your comment.

Overview

Lesson and course session updates return a 500 when the body isn't a JSON object, and creating an attendance session returns a 500 when the same learner appears twice. These should return a 400.

Complexity: Low Target branch: develop

Context

On develop at fe298f5449 (coach):

  • PATCH /api/lessons/lesson/<id>/ with [1] raises TypeError, and with "ab" raises ValueError, from dict(data) in an overridden to_internal_value (lesson.py#L128).
  • PATCH /api/courses/coursesession/<id>/ with [1] raises TypeError from OrderedDict(data) (course_session.py#L173).
  • POST /api/attendance/attendancesession/ with two attendance_records for the same user raises IntegrityError (attendance_session.py#L81).

The Change

  • The lesson and course session serializers should reject a body that isn't a JSON object before converting it.
  • The attendance session serializer should reject duplicate users in attendance_records.

Acceptance Criteria

  • [ ] Each request under Context returns 400 and saves nothing.
  • [ ] Valid lesson, course session and attendance session updates behave as before.
  • [ ] Tests cover each request under Context.

AI usage

I had Claude Code sweep Kolibri's API code for unvalidated request input and reproduce each 500 with a test. I chose the fix and the split into sub-issues. Claude Code drafted the issue to the pattern of #15838.

rtibbles avatar Nov 15 '26 20:11 rtibbles

Hi! πŸ‘‹

This issue is available for contribution and supports self-assignment. Here's how to get started:

  • Comment /assign to assign yourself to this issue
  • You can have up to 2 issues assigned at a time across all community repos
  • Dropping an issue has a 7-day cooldown before the slot opens up
  • Link your pull request to this issue when you submit it

πŸ“– Read the Contributing guidelines before starting.

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Nov 15 '26 21:11 learning-equality-bot

hi, I wanna work on this assign it to me

Arjun8242 avatar Nov 16 '26 12:11 Arjun8242

Hi! πŸ‘‹

Thanks for your interest! This issue supports self-assignment. Comment /assign to assign yourself.

Visit Contributing guidelines to learn about the contributing process. 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Nov 16 '26 12:11 learning-equality-bot

/assign

Arjun8242 avatar Nov 16 '26 12:11 Arjun8242

Hi! πŸ‘‹

You've been assigned to this issue. Here's what to do next:

  • Read the issue description carefully and make sure you understand the requirements
  • Link your pull request to this issue when you submit it
  • If you can no longer work on this, unassign yourself so others can pick it up

Good luck! 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Nov 16 '26 12:11 learning-equality-bot

/assign

abhishekreddychitukula avatar Nov 27 '26 17:11 abhishekreddychitukula

Hi! πŸ‘‹

Thanks so much for your interest! This issue is already assigned. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.

We really appreciate your willingness to help. 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Nov 27 '26 17:11 learning-equality-bot