Improve parse_role
's error handling
#4656
Labels
deck-scrubbing
Tech debt or other between-initiative tidy-up work
parse_role
's error handling
#4656
parse_role
accepts a dotted path to a role class and returns the role class itself (jobserver/authorization/roles.py
). As you can see below, it validates the dotted path and callsimport_string
, which raises anImportError
if the import fails.job-server/jobserver/authorization/parsing.py
Lines 4 to 24 in aa5e326
If a role class is removed, and dotted paths to that role class are present in the database, then
parse_role
will raise anImportError
when called. This seems most likely when therole_description
template tag is called; in these cases, the user would receive a 500 error, and we would receive a notification from Sentry.We were tripped up by this issue when we deployed #4636. Because the merge, the deployment, and the notification happened in quick succession, it was easy to back out (#4638). However, the notifications could have been clearer. See, for example: https://ebm-datalab.sentry.io/issues/5935887041/. For this reason, I think we should use a custom error with a more informative error message. Doing so would involve something like...
The text was updated successfully, but these errors were encountered: