From d7b95c3ed714d53bef16c5009f8fe7bc9ae8497e 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 331ea01fdc198..07d77554424c8 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1034,6 +1034,9 @@ func newIssueAttempt(repo *Repository, issue *Issue, labelIDs []int64, uuids []s // 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 222b3be4343cb87bf6b23531a436c7db4a1d15e5 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 07d77554424c8..f115d762177b3 100644 --- a/models/issue.go +++ b/models/issue.go @@ -1035,7 +1035,7 @@ func newIssueAttempt(repo *Repository, issue *Issue, labelIDs []int64, uuids []s // 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,