Skip to content

Repository owner can be nil if deleted and that breaks the listing of repositories.  #24857

Open
@sergiotarxz

Description

@sergiotarxz

Description

I do not know if it is still posible to reach a point where deleting a owner does not delete its repositories, but is was once possible and failure to handle that breaks the lists of repositories.

Before patching it myself to avoid the bug.- By not listing repositories without owner.- this url would throw a 500 error.
https://git.owlcode.tech/explore/repos?page=2&sort=recentupdate&q=&topic=false&language=&only_show_relevant=false

2023/05/16 18:17:38 ...s/context/context.go:263:HTML() [E] [6463aca2] Render failed: template: explore/repo_list:29:19: executing "explore/repo_list" at <.Owner.Visibility.IsPrivate>: nil pointer evaluating *user.User.Visibility
        in template file (builtin) templates/explore/repo_list.tmpl (subtemplate of explore/repos):
        ----------------------------------------------------------------------
                                                                        <span class="ui basic label">{{$.locale.Tr "repo.desc.private"}}</span>
                                                                {{else}}
                                                                        {{if .Owner.Visibility.IsPrivate}}
                                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ----------------------------------------------------------------------

Gitea Version

1.19.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.39.3

Operating System

Gentoo GNU/Linux

How are you running Gitea?

Built from portage renaming the ebuild to point the lastest upstream version to see if that solved the bug, it did not.

I have added this patch to /etc/portage/patches to avoid the bug:

diff --git a/routers/web/explore/repo.go b/routers/web/explore/repo.go
index be5ad1b..79db4a9 100644
--- a/routers/web/explore/repo.go
+++ b/routers/web/explore/repo.go
@@ -113,6 +113,14 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
 		IncludeDescription: setting.UI.SearchRepoDescription,
 		OnlyShowRelevant:   opts.OnlyShowRelevant,
 	})
+	old_repos := repos
+	repos = nil
+	for _, item := range old_repos {
+		if item.Owner != nil {
+			repos = append(repos, item)
+		}
+	}
+
 	if err != nil {
 		ctx.ServerError("SearchRepository", err)
 		return

Database

PostgreSQL

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions