Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/sentry/integrations/github/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def get(self, request, organization, integration_id):
except ApiError as err:
if err.code == 403:
return Response({'detail': 'Rate limit exceeded'}, status=429)
if err.code == 422:
return Response({
'detail': 'Repositories could not be searched because they do not exist, or you do not have access to them.'
}, status=404)
raise
return Response([{
'label': i['name'],
Expand Down
24 changes: 24 additions & 0 deletions tests/sentry/integrations/github/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ def test_finds_repo_results(self):
{'value': 'test/exhaust', 'label': 'exhaust'}
]

@responses.activate
def test_repo_search_validation_error(self):
responses.add(
responses.GET,
self.base_url + '/search/repositories?q=org:test%20nope',
json={
'message': 'Validation Error',
'errors': [
{'message': 'Cannot search for that org'}
]
},
status=422
)
resp = self.client.get(
self.url,
data={
'field': 'repo',
'query': 'nope',
'repo': 'example',
}
)
assert resp.status_code == 404
assert 'detail' in resp.data

@responses.activate
def test_finds_no_external_issues_results(self):
responses.add(
Expand Down