diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go index 489b22892a..bd76e4d37e 100644 --- a/routers/api/v1/org/team.go +++ b/routers/api/v1/org/team.go @@ -591,6 +591,7 @@ func GetTeamRepos(ctx *context.APIContext) { // Due to the pagination of the API it doesn't make sense to skip it, as we wouldn't be giving the right // number of results back to the API consumer. ctx.Error(http.StatusInternalServerError, "InvalidAuthorizationReducer", "Repository was available from GetTeamRepositories, but not readable.") + return } repos[i] = convert.ToRepo(ctx, repo, permission) } diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 5c11a2380f..793281bc79 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -234,11 +234,13 @@ func Search(ctx *context.APIContext) { OK: false, Error: err.Error(), }) + return } else if !permission.HasAccess() { // It shouldn't happen that a repo is returned from GetTeamRepositories which we have no access to at all. // Due to the pagination of the API it doesn't make sense to skip it, as we wouldn't be giving the right // number of results back to the API consumer. ctx.Error(http.StatusInternalServerError, "InvalidAuthorizationReducer", "Repository was available from SearchRepository, but not readable.") + return } results[i] = convert.ToRepo(ctx, repo, permission) diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go index 92d86e10b0..6897d06ca0 100644 --- a/routers/api/v1/user/repo.go +++ b/routers/api/v1/user/repo.go @@ -153,11 +153,13 @@ func ListMyRepos(ctx *context.APIContext) { permission, err := access_model.GetUserRepoPermissionWithReducer(ctx, repo, ctx.Doer, ctx.Reducer) if err != nil { ctx.Error(http.StatusInternalServerError, "GetUserRepoPermissionWithReducer", err) + return } else if !permission.HasAccess() { // It shouldn't happen that a repo is returned from SearchRepository which we have no access to at all. Due // to the pagination of the API it doesn't make sense to skip it, as we wouldn't be giving the right number // of results back to the API consumer. ctx.Error(http.StatusInternalServerError, "InvalidAuthorizationReducer", "Repository was available from SearchRepository, but not readable.") + return } results[i] = convert.ToRepo(ctx, repo, permission) }