Skip to content

Commit 5705f72

Browse files
authored
Prevent panic when editing forked repos by API (#14960)
When editing forked repos using the API the BaseRepository needs to loaded in order to check its visibility otherwise there will be NPE panic. Fix #14956 Signed-off-by: Andrew Thornton <[email protected]>
1 parent c8e5c79 commit 5705f72

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

routers/api/v1/repo/repo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,10 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
556556
if opts.Private != nil {
557557
// Visibility of forked repository is forced sync with base repository.
558558
if repo.IsFork {
559+
if err := repo.GetBaseRepo(); err != nil {
560+
ctx.Error(http.StatusInternalServerError, "Unable to load base repository", err)
561+
return err
562+
}
559563
*opts.Private = repo.BaseRepo.IsPrivate
560564
}
561565

0 commit comments

Comments
 (0)