Skip to content

Commit 33c2c49

Browse files
6543zeripath
andauthored
Prevent panic when editing forked repos by API (#14960) (#14963)
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]> Co-authored-by: zeripath <[email protected]>
1 parent 05ac72c commit 33c2c49

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
@@ -539,6 +539,10 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
539539
if opts.Private != nil {
540540
// Visibility of forked repository is forced sync with base repository.
541541
if repo.IsFork {
542+
if err := repo.GetBaseRepo(); err != nil {
543+
ctx.Error(http.StatusInternalServerError, "Unable to load base repository", err)
544+
return err
545+
}
542546
*opts.Private = repo.BaseRepo.IsPrivate
543547
}
544548

0 commit comments

Comments
 (0)