fix permission denied error for non existing projects (#17586) (#17619)

Signed-off-by: Maksym Trofimenko <maksym@container-registry.com>
This commit is contained in:
Maksym Trofimenko 2022-11-14 04:01:20 +00:00 committed by GitHub
parent 40ba15ca5a
commit 6b46b8bf26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,7 +85,11 @@ func (b *BaseAPI) HasProjectPermission(ctx context.Context, projectIDOrName inte
p, err := baseProjectCtl.GetByName(ctx, projectName) p, err := baseProjectCtl.GetByName(ctx, projectName)
if err != nil { if err != nil {
log.Errorf("failed to get project %s: %v", projectName, err) log.Errorf("failed to get project %s: %v", projectName, err)
return false if errors.IsNotFoundErr(err) {
p = &project.Project{}
} else {
return false
}
} }
if p == nil { if p == nil {
log.Warningf("project %s not found", projectName) log.Warningf("project %s not found", projectName)