From 5d6ab6576142a4b0b4f5fa5b53aa4ddeea8e302e Mon Sep 17 00:00:00 2001 From: Norwin Roosen Date: Mon, 12 Jul 2021 17:32:26 +0200 Subject: [PATCH 1/2] dont try to find issue when index == 0 --- models/issue.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/issue.go b/models/issue.go index b9643ae00ec42..1febd94e29253 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, fmt.Errorf("index %d is not a valid issue", index) + } issue := &Issue{ RepoID: repoID, Index: index, From b10b7d83d1f5a71ab7a9c1e865d1739443ae4ea4 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Mon, 12 Jul 2021 20:51:18 +0200 Subject: [PATCH 2/2] show 404 --- models/issue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/issue.go b/models/issue.go index 1febd94e29253..225dfee20f095 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1019,7 +1019,7 @@ 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, fmt.Errorf("index %d is not a valid issue", index) + return nil, ErrIssueNotExist{} } issue := &Issue{ RepoID: repoID,