Problem
update_schedule_json does json.loads(request.GET['sections']) and assumes the result is a list of section IDs.
But json.loads can return dict/int/string/etc., and later set-math assumes a list of ints.
Examples
- sections="{}" parses to dict => treated like empty set => can remove all sections (dangerous)
- sections="5" parses to int => set(5) TypeError => 500 crash
- sections='["abc", 12, 12]' includes junk + duplicates
The issue is currently in esp/esp/program/modules/handlers/onsiteclasslist.py -> update_schedule_json
Acceptance
- sections="{}" -> HTTP 400 + JSON error message
- sections="5" -> HTTP 400 + JSON error message
- valid list works normally end-to-end
Steps to Reproduce
- We have a Program with onsite module enabled.
- We have a valid student user ID (replace <USER_ID>).
- The student is enrolled in at least one section (for the “schedule wipe” repro).
- Replace and <PROGRAM_URL> with your environment.
Expected Behavior
Expected
Return HTTP 400 with JSON error if sections is not a JSON list.
Sanitise list: cast to int, drop invalid, dedupe, and enforce max length.
Actual Behavior
Right now the code does:
- desired_sections = json.loads(request.GET['sections'])
- Later, it does set(desired_sections) and assumes it’s a list of ints
- But json.loads() can return a dict, int, string, etc. — and that can:
- wipe schedules (e.g. {} becomes empty set)
- 500 crash (e.g. "5" becomes int → set(5) crashes)
This is visible in the current code inside update_schedule_json
Screenshots
No response
Operating System
MAC OS
Browser
Chrome latest
Additional Context
No response
Problem
update_schedule_json does json.loads(request.GET['sections']) and assumes the result is a list of section IDs.
But json.loads can return dict/int/string/etc., and later set-math assumes a list of ints.
Examples
The issue is currently in esp/esp/program/modules/handlers/onsiteclasslist.py -> update_schedule_json
Acceptance
Steps to Reproduce
Expected Behavior
Expected
Return HTTP 400 with JSON error if sections is not a JSON list.
Sanitise list: cast to int, drop invalid, dedupe, and enforce max length.
Actual Behavior
Right now the code does:
This is visible in the current code inside update_schedule_json
Screenshots
No response
Operating System
MAC OS
Browser
Chrome latest
Additional Context
No response