TypeError in OAuthCredentials.__str__ when some credentials have no token in the admin
Sentry Issue: ARKINDEX-BACKEND-WY
TypeError: 'NoneType' object is not subscriptable
(50 additional frame(s) were not displayed)
...
File "django/forms/widgets.py", line 592, in optgroups
for index, (option_value, option_label) in enumerate(self.choices):
File "django/forms/models.py", line 1170, in __iter__
yield self.choice(obj)
File "django/forms/models.py", line 1184, in choice
self.field.label_from_instance(obj),
File "django/forms/models.py", line 1253, in label_from_instance
return str(obj)
File "arkindex/users/models.py", line 169, in __str__
- Go to Profile > OAuth
- Select Gitlab in the provider list
- Type in a invalid URL like
https://eijsiofjseoifjsio
in the URL field - Try to authenticate
- Watch the browser get sad
- Open the Django admin, head over to the OAuth credentials list and find the credentials you just created
- Enjoy the HTTP 500
It seems any OAuthCredentials with a null
token will cause this error, since __str__
relies on the token.
Edited by Erwan Rouchet