Make Repository.provider_name and OAuthCredentials.provider_name constants
Sentry Issue: ARKINDEX-BACKEND-17A
ValueError: Empty provider_name
(15 additional frame(s) were not displayed)
...
File "rest_framework/serializers.py", line 502, in to_representation
attribute = field.get_attribute(instance)
File "rest_framework/fields.py", line 457, in get_attribute
return get_attribute(instance, self.source_attrs)
File "rest_framework/fields.py", line 97, in get_attribute
instance = getattr(instance, attr)
File "arkindex/dataimport/models.py", line 601, in enabled
File "arkindex/dataimport/models.py", line 590, in provider_class
There has been some errors because provider_name
can be an empty string, but everything in the backend expects the OAuth or Git provider to actually exists. Finding the exact places where a provider_name
can be empty is time-consuming and could just be pointless: we should only ever have one provider name, gitlab
.
We want to keep this provider system so that we can still connect to other services with OAuth2 or support Git repos from other hosting services, because we have no idea if Arkindex will or will not need this, and having to remove then restore this abstraction layer would waste a lot of time.
However, this provider system does not ever care about the fact that provider_name
is a database field or not: we could just turn Repository.provider_name
and OAuthCredentials.provider_name
into constant class attributes, instead of actual database fields. We would just have to turn them back to actual fields when we want to be able to change to different values. Making the fields constant will delay any possible provider troubles until we actually need multiple providers.