apluslms / a-plus

A+ frontend portal - A+ LMS documentation:
https://apluslms.github.io/
Other
67 stars 72 forks source link

Infinite loop in course configuration with error message "Category requires a name." #692

Open atilante opened 3 years ago

atilante commented 3 years ago

It is possible to cause an infinite loop in A+ course configuration. This seems to happen if there are no submit exercises on the course. I encountered this phenomenon when creating a modified version of the Data Structures and Algorithms Y course for research purposes.

How to reproduce this behaviour:

  1. Clone the Data Structures and Algorithms Y repository, branch aplus-infinite-loop-bug:

git clone -b aplus-infinite-loop-bug git@version.aalto.fi:course/traky.git traky

  1. Compile the CS-A1141 version of the course.

cd traky git submodule init && git submodule update ./docker-compile.sh 1141

  1. Start A+ and MOOC-grader locally.

./docker-up.sh

  1. The script ends up repeating the following lines:

plus_1 | [aplus course update] Note: defined settings.BASE_URL from environment plus_1 | [aplus course update] Note: defined settings.SECRET_KEY_FILE from environment plus_1 | [aplus course update] Note: defined settings.LOCAL_SETTINGS from environment plus_1 | [aplus course update] Installing logger for deferred model fields... plus_1 | [aplus course update] CommandError: Configuration failed! plus_1 | [aplus course update] Category requires a name.

The location of the error message in the A+ source code seems to be https://github.com/apluslms/a-plus/blob/master/edit_course/operations/configure.py#L422 .

If one uncomments a submit exercise with key my_sort in the following files, the course configures normally:

I see two issues here:

  1. The infinite loop;
  2. Unhelpful error message.

Sidenote: the course currently uses my fork of A+ RST tools, but that does not likely cause the bug; modifications in my fork have been merged to the official repository in pull request https://github.com/apluslms/a-plus-rst-tools/pull/92 .

markkuriekkinen commented 3 years ago

Actually, the issue is that a-plus-rst-tools assumes that the course always has at least one exercise in the "submit" category. That should be fixed in the a-plus-rst-tools. It has a low priority since this rarely affects typical courses.

The infinite loop in the run-aplus-front container is intentional. It tries to import the course in a loop because it may fail on the first time if the grader container is slow to start up.

The error message CommandError: Configuration failed! Category requires a name. describes the situation accurately from the perspective of A+. A+ processes the JSON course configuration and sees a category definition that does not have any name. If I remember correctly, the JSON does not have any other key for categories so there is no key that could be printed in the error message. It is an unnamed category definition, but creating a category in the A+ database requires a name.