From f79f8e13e37fc699800318a20cb2866a326c467e Mon Sep 17 00:00:00 2001 From: Giteabot Date: Thu, 14 Nov 2024 12:47:04 +0800 Subject: [PATCH] Fix nil panic if repo doesn't exist (#32501) (#32502) Backport #32501 by wxiaoguang fix #32496 Co-authored-by: wxiaoguang --- models/activities/action.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/activities/action.go b/models/activities/action.go index a99df558cb..95132f9ced 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -248,6 +248,9 @@ func (a *Action) GetActDisplayNameTitle(ctx context.Context) string { // GetRepoUserName returns the name of the action repository owner. func (a *Action) GetRepoUserName(ctx context.Context) string { a.loadRepo(ctx) + if a.Repo == nil { + return "(non-existing-repo)" + } return a.Repo.OwnerName } @@ -260,6 +263,9 @@ func (a *Action) ShortRepoUserName(ctx context.Context) string { // GetRepoName returns the name of the action repository. func (a *Action) GetRepoName(ctx context.Context) string { a.loadRepo(ctx) + if a.Repo == nil { + return "(non-existing-repo)" + } return a.Repo.Name }