Browse Source

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 <art27@cantab.net>
tags/v1.15.0-dev
zeripath GitHub 4 years ago
parent
commit
8d7ac4c6f8
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      routers/api/v1/repo/repo.go

+ 4
- 0
routers/api/v1/repo/repo.go View File

@@ -556,6 +556,10 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
if opts.Private != nil {
// Visibility of forked repository is forced sync with base repository.
if repo.IsFork {
if err := repo.GetBaseRepo(); err != nil {
ctx.Error(http.StatusInternalServerError, "Unable to load base repository", err)
return err
}
*opts.Private = repo.BaseRepo.IsPrivate
}



Loading…
Cancel
Save