apluslms / radar

Web service for analyzing program code similarity
4 stars 10 forks source link

Fix KeyError when displaying errors from a celery task #19

Closed Gehock closed 3 years ago

Gehock commented 3 years ago

Description

Fixes the following error that occurs when get_full_course_config task fails to fetch course data:

Apr 28 14:41:35 hostname radar_celery_main[421877]: [2021-04-28 11:41:35,176: INFO/MainProcess] Received task: provider.tasks.get_full_course_config[29d8f62b-8ee0-42e8-86af-564262bd83f6]
Apr 28 14:41:35 hostname radar_celery_main[421900]: [2021-04-28 11:41:35,381: ERROR/ForkPoolWorker-1] Task provider.tasks.get_full_course_config[29d8f62b-8ee0-42e8-86af-564262bd83f6] raised unexpected: KeyError('errors')
Apr 28 14:41:35 hostname radar_celery_main[421900]: Traceback (most recent call last):
Apr 28 14:41:35 hostname radar_celery_main[421900]:   File "/srv/radar/venv/lib/python3.8/site-packages/celery/app/trace.py", line 405, in trace_task
Apr 28 14:41:35 hostname radar_celery_main[421900]:     R = retval = fun(*args, **kwargs)
Apr 28 14:41:35 hostname radar_celery_main[421900]:   File "/srv/radar/venv/lib/python3.8/site-packages/celery/app/trace.py", line 697, in __protected_call__
Apr 28 14:41:35 hostname radar_celery_main[421900]:     return self.run(*args, **kwargs)
Apr 28 14:41:35 hostname radar_celery_main[421900]:   File "/srv/radar/radar/provider/tasks.py", line 189, in get_full_course_config
Apr 28 14:41:35 hostname radar_celery_main[421900]:     result["errors"].append("No exercises found for %s" % repr(course))
Apr 28 14:41:35 hostname radar_celery_main[421900]: KeyError: 'errors'

What type of test did you run?

Tested fetching course data in a test environment and inspected the radar_celery_main log.

Is it Done?

Clean up your git commit history before submitting the pull request!