@@ -855,6 +855,7 @@ func (p *Plugin) searchIssues(c *UserContext, w http.ResponseWriter, r *http.Req
855
855
orgsList = []string {"" }
856
856
}
857
857
858
+ hasFetchedIssues := false
858
859
for _ , org := range orgsList {
859
860
query := getIssuesSearchQuery (org , searchTerm )
860
861
var result * github.IssuesSearchResult
@@ -868,11 +869,17 @@ func (p *Plugin) searchIssues(c *UserContext, w http.ResponseWriter, r *http.Req
868
869
})
869
870
if cErr != nil {
870
871
c .Log .WithError (cErr ).With (logger.LogContext {"query" : query }).Warnf ("Failed to search for issues" )
871
- p .writeJSON (w , make ([]* github.Issue , 0 ))
872
- return
873
872
}
874
873
875
- allIssues = append (allIssues , result .Issues ... )
874
+ if result != nil && len (result .Issues ) > 0 {
875
+ allIssues = append (allIssues , result .Issues ... )
876
+ hasFetchedIssues = true
877
+ }
878
+ }
879
+
880
+ if ! hasFetchedIssues {
881
+ p .writeJSON (w , make ([]* github.Issue , 0 ))
882
+ return
876
883
}
877
884
878
885
p .writeJSON (w , allIssues )
@@ -1407,27 +1414,30 @@ func (p *Plugin) getRepositories(c *UserContext, w http.ResponseWriter, r *http.
1407
1414
}
1408
1415
} else {
1409
1416
orgsList := p .configuration .getOrganizations ()
1417
+ hasFetchedRepos := false
1410
1418
for _ , org := range orgsList {
1411
1419
orgRepos , statusCode , err := p .getRepositoryListByOrg (c .Ctx , c .GHInfo , org , githubClient , opt )
1412
1420
if err != nil {
1413
1421
if statusCode == http .StatusNotFound {
1414
1422
orgRepos , err = p .getRepositoryList (c .Ctx , c .GHInfo , org , githubClient , opt )
1415
1423
if err != nil {
1416
1424
c .Log .WithError (err ).Warnf ("Failed to list repositories" , "Organization" , org )
1417
- p .writeAPIError (w , & APIErrorResponse {Message : "Failed to fetch repositories" , StatusCode : http .StatusInternalServerError })
1418
- return
1419
1425
}
1420
1426
} else {
1421
1427
c .Log .WithError (err ).Warnf ("Failed to list repositories" , "Organization" , org )
1422
- p .writeAPIError (w , & APIErrorResponse {Message : "Failed to fetch repositories" , StatusCode : http .StatusInternalServerError })
1423
- return
1424
1428
}
1425
1429
}
1426
1430
1427
1431
if len (orgRepos ) > 0 {
1428
1432
allRepos = append (allRepos , orgRepos ... )
1433
+ hasFetchedRepos = true
1429
1434
}
1430
1435
}
1436
+
1437
+ if ! hasFetchedRepos {
1438
+ p .writeAPIError (w , & APIErrorResponse {Message : "Failed to fetch repositories" , StatusCode : http .StatusInternalServerError })
1439
+ return
1440
+ }
1431
1441
}
1432
1442
1433
1443
repoResp := make ([]RepoResponse , len (allRepos ))
0 commit comments