Stale read on ListExternalRepositories

Bastien Abadie
2022-07-05T14:18:06Z

Sentry Issue: [ARKINDEX-BACKEND-2N](https://sentry.io/organizations/teklia/issues/1839007060/?referrer=gitlab_integration)

```
Corpus.DoesNotExist: Corpus matching query does not exist.
(10 additional frame(s) were not displayed)
...
...

Sentry Issue: ARKINDEX-BACKEND-2N

Corpus.DoesNotExist: Corpus matching query does not exist.
(10 additional frame(s) were not displayed)
...
  File "arkindex/dataimport/api.py", line 480, in create
  File "rest_framework/serializers.py", line 234, in is_valid
    self._validated_data = self.run_validation(self.initial_data)
  File "rest_framework/serializers.py", line 433, in run_validation
    value = self.to_internal_value(data)
  File "arkindex/dataimport/serializers/git.py", line 142, in to_internal_value
  File "django/db/models/query.py", line 408, in get
    self.model._meta.object_name

Internal Server Error: /api/v1/imports/repos/search/bc7e2210-2ef6-4517-9341-1cefd110d276/

This issue can more easily happen when using the New project button on the repo selection page in production: right after creating a corpus, the search is performed, but the Postgres cluster might not have replicated the new corpus yet, causing the Corpus.DoesNotExist. This can also happen on any read-only corpora.