# Buggy code
def clean_repo_link(self):
    """Validate repository link."""
    try:
        repo = Component.objects.get_linked(self.repo)
        if repo is not None and repo.is_repo_link:
            raise ValidationError(
                {
                    "repo": _(
                        "Invalid link to a Weblate project, "
                        "cannot link to linked repository!"
                    )
                }
            )
        if repo.pk == self.pk:
            raise ValidationError(
                {
                    "repo": _(
                        "Invalid link to a Weblate project, cannot link it to itself!"
                    )
                }
            )
    except (Component.DoesNotExist, ValueError):
        raise ValidationError(
            {
                "repo": _(
                    "Invalid link to a Weblate project, "
                    "use weblate://project/component."
                )
            }
        )
    for setting in ("push", "branch", "git_export"):
        if getattr(self, setting):
            raise ValidationError(
                {setting: _("Option is not available for linked repositories.")}
            )
    self.linked_component = Component.objects.get_linked(self.repo)


# Traceback (ValidationError)
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/django/forms/models.py", line 404, in _post_clean
self.instance.full_clean(exclude=exclude, validate_unique=False)
File "/usr/local/lib/python3.7/dist-packages/django/db/models/base.py", line 1222, in full_clean
raise ValidationError(errors)

During handling of the above exception ({'git_export': ['Die Option ist für verknüpfte Repositories nicht verfügbar.']}), another exception occurred:
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/weblate/trans/views/settings.py", line 79, in change_component
if form.is_valid():
File "/usr/local/lib/python3.7/dist-packages/django/forms/forms.py", line 180, in is_valid
return self.is_bound and not self.errors
File "/usr/local/lib/python3.7/dist-packages/django/forms/forms.py", line 175, in errors
self.full_clean()
File "/usr/local/lib/python3.7/dist-packages/django/forms/forms.py", line 378, in full_clean
self._post_clean()
File "/usr/local/lib/python3.7/dist-packages/django/forms/models.py", line 406, in _post_clean
self._update_errors(e)
File "/usr/local/lib/python3.7/dist-packages/django/forms/models.py", line 380, in _update_errors
self.add_error(None, errors)
File "/usr/local/lib/python3.7/dist-packages/django/forms/forms.py", line 348, in add_error
"'%s' has no field named '%s'." % (self.__class__.__name__, field))

Exception Type: ValueError at /settings/project/component/
Exception Value: 'ComponentSettingsForm' has no field named 'git_export'.

# Fixed code
def clean_repo_link(self):
    """Validate repository link."""
    try:
        repo = Component.objects.get_linked(self.repo)
        if repo is not None and repo.is_repo_link:
            raise ValidationError(
                {
                    "repo": _(
                        "Invalid link to a Weblate project, "
                        "cannot link to linked repository!"
                    )
                }
            )
        if repo.pk == self.pk:
            raise ValidationError(
                {
                    "repo": _(
                        "Invalid link to a Weblate project, cannot link it to itself!"
                    )
                }
            )
    except (Component.DoesNotExist, ValueError):
        raise ValidationError(
            {
                "repo": _(
                    "Invalid link to a Weblate project, "
                    "use weblate://project/component."
                )
            }
        )
    for setting in ("push", "branch", "git_export"):
        # The git_export might be missing in case of form validation
        if getattr(self, setting, None):
            raise ValidationError(
                {setting: _("Option is not available for linked repositories.")}
            )
    self.linked_component = Component.objects.get_linked(self.repo)