From 03ab73d92eabaf774278effe3332623b1dc3580a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 14 Nov 2024 12:17:58 +0800 Subject: [PATCH] Fix nil panic if repo doesn't exist (#32501) fix #32496 (cherry picked from commit 985e2a8af3d6468bac3ab178148c38bdbd8414f5) --- models/activities/action.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/activities/action.go b/models/activities/action.go index b6c816f096..dd67b98242 100644 --- a/models/activities/action.go +++ b/models/activities/action.go @@ -250,6 +250,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 } @@ -262,6 +265,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 }