Loading
Completion endpoint answers 500 to data of another shape
Closes #3638136.
The completion endpoint checks the shape of the decoded body before anything is changed and answers 400 with a message that names the wrong part (e.g. Invalid data: the entry of course 12 is not an object.), instead of a TypeError and 500. The empty body of Moodle's connection test keeps its answer.
MoodleCompletionRestResource::invalidData(): an object of course entries, each an object;totala number;usersan object of objects.- Unit test
CompletionDataTestcovers the accepted shapes and every refused one. - Tested against a site with the REST resource:
{}→ 200,{"12":1},{"userid":1,"courseid":1},{"12":{"users":7}},"x"→ 400, a valid entry → 200.
The fix is one commit of its own, the CHANGELOG entry a second one.