introduce sentinel error when pr has no poster

This commit is contained in:
Clouds 2026-06-20 08:48:12 +02:00
commit 1fb011c4ea
3 changed files with 6 additions and 3 deletions

View file

@ -80,7 +80,10 @@ func (err ErrIssueWasClosed) Error() string {
return fmt.Sprintf("Issue [%d] %d was already closed", err.ID, err.Index)
}
var ErrIssueAlreadyChanged = util.NewInvalidArgumentErrorf("the issue is already changed")
var (
ErrIssueAlreadyChanged = util.NewInvalidArgumentErrorf("the issue is already changed")
ErrNoPosterSetOnIssue = errors.New("the issue has no poster")
)
// Issue represents an issue or pull request of repository.
type Issue struct {

View file

@ -45,7 +45,7 @@ func mustGetIssuePoster(ctx context.Context, issue *issues_model.Issue) (*user_m
return issue.Poster, nil
}
if issue.PosterID == 0 {
return nil, user_model.ErrUserNotExist{}
return nil, issues_model.ErrNoPosterSetOnIssue
}
poster, err := user_model.GetPossibleUserByID(ctx, issue.PosterID)

View file

@ -392,7 +392,7 @@ func TestActionsTrust_GetPullRequestUserIsTrustedWithActions(t *testing.T) {
t.Run("no poster set on issue linked to pull request", func(t *testing.T) {
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 6000})
posterTrust, err := GetPullRequestPosterIsTrustedWithActions(t.Context(), pr)
require.ErrorIs(t, err, user_model.ErrUserNotExist{})
require.ErrorIs(t, err, issues_model.ErrNoPosterSetOnIssue)
require.Equal(t, UserIsNotTrustedWithActions, posterTrust)
})