loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Avoid user does not exist error when detecting schedule actions when the commit author is an external user (#30357)

![image](https://github.com/go-gitea/gitea/assets/18380374/ddf6ee84-2242-49b9-b066-bd8429ba4d76)

When repo is a mirror, and commit author is an external user, then
`GetUserByEmail` will return error.

reproduce/test:
- mirror Gitea to your instance
- disable action and enable it again, this will trigger
`DetectAndHandleSchedules`

ps: also follow #24706, it only fixed normal runs, not scheduled runs.
(cherry picked from commit 96d31fe0a8b88c09488989cd5459d4124dcb7983)

authored by

yp05327 and committed by
Gergely Nagy
e74865ca a527f5a3

+6 -6
+3
models/actions/schedule_list.go
··· 44 44 schedule.TriggerUser = user_model.NewActionsUser() 45 45 } else { 46 46 schedule.TriggerUser = users[schedule.TriggerUserID] 47 + if schedule.TriggerUser == nil { 48 + schedule.TriggerUser = user_model.NewGhostUser() 49 + } 47 50 } 48 51 } 49 52 return nil
+3 -6
services/actions/notifier_helper.go
··· 560 560 } 561 561 562 562 // We need a notifyInput to call handleSchedules 563 - // Here we use the commit author as the Doer of the notifyInput 564 - commitUser, err := user_model.GetUserByEmail(ctx, commit.Author.Email) 565 - if err != nil { 566 - return fmt.Errorf("get user by email: %w", err) 567 - } 568 - notifyInput := newNotifyInput(repo, commitUser, webhook_module.HookEventSchedule) 563 + // if repo is a mirror, commit author maybe an external user, 564 + // so we use action user as the Doer of the notifyInput 565 + notifyInput := newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) 569 566 570 567 return handleSchedules(ctx, scheduleWorkflows, commit, notifyInput, repo.DefaultBranch) 571 568 }