diff --git a/integrations/api_releases_test.go b/integrations/api_releases_test.go index 870d7d0e64d..2b310d11e08 100644 --- a/integrations/api_releases_test.go +++ b/integrations/api_releases_test.go @@ -7,7 +7,6 @@ package integrations import ( "fmt" "net/http" - "strings" "testing" "code.gitea.io/gitea/models" @@ -152,7 +151,7 @@ func TestAPIGetReleaseByTag(t *testing.T) { var err *api.APIError DecodeJSON(t, resp, &err) - assert.True(t, strings.HasPrefix(err.Message, "release tag does not exist")) + assert.EqualValues(t, "Not Found", err.Message) } func TestAPIDeleteTagByName(t *testing.T) { diff --git a/routers/api/v1/repo/release_tags.go b/routers/api/v1/repo/release_tags.go index ef07ce5e1ad..70011a6a8ed 100644 --- a/routers/api/v1/repo/release_tags.go +++ b/routers/api/v1/repo/release_tags.go @@ -48,14 +48,19 @@ func GetReleaseTag(ctx *context.APIContext) { release, err := models.GetRelease(ctx.Repo.Repository.ID, tag) if err != nil { if models.IsErrReleaseNotExist(err) { - ctx.Error(http.StatusNotFound, "GetRelease", err) + ctx.NotFound() return } ctx.Error(http.StatusInternalServerError, "GetRelease", err) return } - if err := release.LoadAttributes(); err != nil { + if release.IsTag { + ctx.NotFound() + return + } + + if err = release.LoadAttributes(); err != nil { ctx.Error(http.StatusInternalServerError, "LoadAttributes", err) return }