diff --git a/models/issue.go b/models/issue.go index b9643ae00ec42..225dfee20f095 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1018,6 +1018,9 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) // GetIssueByIndex returns raw issue without loading attributes by index in a repository. func GetIssueByIndex(repoID, index int64) (*Issue, error) { + if index < 1 { + return nil, ErrIssueNotExist{} + } issue := &Issue{ RepoID: repoID, Index: index,