Skip to content

Commit 69fcca2

Browse files
RaymondKroonlunny6543wxiaoguang
authored
Remove deleted repos from searchresult (#21512)
This prevents a 500 response, because null pointer exceptions in rendering the template. This happends bc the repoId is not in the repoMap because it is delete fix #19076 Co-authored-by: Lunny Xiao <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 2c77d4b commit 69fcca2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

routers/web/explore/code.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,18 @@ func Code(ctx *context.Context) {
110110
}
111111

112112
ctx.Data["RepoMaps"] = repoMaps
113+
114+
if len(loadRepoIDs) != len(repoMaps) {
115+
// Remove deleted repos from search results
116+
cleanedSearchResults := make([]*code_indexer.Result, 0, len(repoMaps))
117+
for _, sr := range searchResults {
118+
if _, found := repoMaps[sr.RepoID]; found {
119+
cleanedSearchResults = append(cleanedSearchResults, sr)
120+
}
121+
}
122+
123+
searchResults = cleanedSearchResults
124+
}
113125
}
114126

115127
ctx.Data["SearchResults"] = searchResults

0 commit comments

Comments
 (0)