(Note: this will likely always fail in dev because the dev database is out of sync. If you don't get the AttributeError in dev, you might need to try this on nest).
The following error will be produced:
Traceback (most recent call last):
File "/data/motacilla/sites/library_website/./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/data/motacilla/venv3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/data/motacilla/venv3.9/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/data/motacilla/venv3.9/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/data/motacilla/venv3.9/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/data/motacilla/sites/library_website/staff/management/commands/list_staff_wagtail.py", line 96, in handle
return staff_report.tab_delimited()
File "/data/motacilla/sites/library_website/staff/utils.py", line 358, in tab_delimited
output = output + self._get_staff_out_of_sync_tab_delimited()
File "/data/motacilla/sites/library_website/staff/utils.py", line 502, in _get_staff_out_of_sync_tab_delimited
for record in self._get_staff_out_of_sync_data():
File "/data/motacilla/sites/library_website/staff/utils.py", line 454, in _get_staff_out_of_sync_data
missing_in_campus_directory, missing_in_wagtail = self._staff_out_of_sync(
File "/data/motacilla/sites/library_website/staff/utils.py", line 435, in _staff_out_of_sync
d.library_unit.get_campus_directory_full_name(),
AttributeError: 'NoneType' object has no attribute 'get_campus_directory_full_name'
Related code
staff/utils.py
Other information:
This can be easily patched by wrapping the code on line 435 in staff/utils.py in a try/except that catches an AttributeError, however, it might more appropriately be solved by testing for None and leaving a comment so that we know in the code why this is happening and don't accidentally ignore a different kind of fail case. We should write a unit test to test for this case as well.
Expected behavior
If a staff member erroneously has an empty unit assigned, the out of sync staff report should not fail.
Actual behavior
If a staff member is assigned an empty unit, the out of sync staff report fails in cron.
Steps to reproduce
StaffPage
for any Library employee.Now running the out of sync staff command will fail with an
AttributeError
:(Note: this will likely always fail in dev because the dev database is out of sync. If you don't get the
AttributeError
in dev, you might need to try this onnest
).The following error will be produced:
Related code
Other information:
This can be easily patched by wrapping the code on line
435
instaff/utils.py
in a try/except that catches anAttributeError
, however, it might more appropriately be solved by testing forNone
and leaving a comment so that we know in the code why this is happening and don't accidentally ignore a different kind of fail case. We should write a unit test to test for this case as well.