Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-83582

Improve LTI NRPS error handling (deletes all students on error currently)

XMLWordPrintable

      Hello! We're a SIS providing LTI Advantage links into Moodle, and last week one of our customers encountered some unfortunately behavior: one of our webservers crashed and during automated failover, there was a proxy hiccup and for a few minutes our system responded with blank HTTP 200s for a subset of requests routed to that server.

      Unfortunately, there was a Moodle LTI course roster sync happening during this window, and our system responded with these blank HTTP 200s.

      Reading through the Moodle code for roster syncing (LtiServiceConnector::getResultsFromResponse), there do not appear to be any checks in place that valid JSON was received from the server, and so currently any sort of parse error or blank document is null coalesced into an empty array, as long as an HTTP 2XX was received. 

      This empty array then caused all students, grades, etc to be deleted from the Moodle courses, and even when they were inserted back into the course a few minute later on the next sync (after the failover had recovered), all the grades, activities, etc were gone, and had to be restored from backup because there were too many students affected to re-add by hand.

      We'll try hard not to return blank HTTP 200s on our end, but I was also wondering if either:

      1) Error checks could be added to LtiServiceConnector::getResultsFromResponse that a well-formed JSON document with a 'body' key was received, and raise otherwise.

      or

      2) When LTI students are added back to a Moodle course in an automated fashion, could their grades/activities/etc be recovered automatically?

      Thanks for considering! In addition to failover situations like ours, I also believe the current code may be susceptible to sporadic network request errors that could lead to invalid JSON: `json_decode('{"asdf": ...', true )` seems to return NULL and would hence be coalesced to `[]`.

            Unassigned Unassigned
            james@populi James Hill
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.