diff options
author | Yevhen Pavlov <yevhen.pavlov.ua@gmail.com> | 2023-05-21 05:54:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-21 10:54:28 +0800 |
commit | 1dfaf83798e1ea4b994fb13924fffe403f8e2e11 (patch) | |
tree | 633871fb32ddc4c504b7557d2af1f2bfba8bccb8 /routers/api/v1 | |
parent | 6b33152b7dc81b38e5832a30c52cfad1902e86d0 (diff) | |
download | gitea-1dfaf83798e1ea4b994fb13924fffe403f8e2e11.tar.gz gitea-1dfaf83798e1ea4b994fb13924fffe403f8e2e11.zip |
Return `404` in the API if the requested webhooks were not found (#24823)
Should resolve first point of the issue
https://github.com/go-gitea/gitea/issues/24574
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/admin/hooks.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/routers/api/v1/admin/hooks.go b/routers/api/v1/admin/hooks.go index 6a08aa5125..8a095a7def 100644 --- a/routers/api/v1/admin/hooks.go +++ b/routers/api/v1/admin/hooks.go @@ -4,6 +4,7 @@ package admin import ( + "errors" "net/http" "code.gitea.io/gitea/models/webhook" @@ -74,7 +75,11 @@ func GetHook(ctx *context.APIContext) { hookID := ctx.ParamsInt64(":id") hook, err := webhook.GetSystemOrDefaultWebhook(ctx, hookID) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetSystemOrDefaultWebhook", err) + if errors.Is(err, util.ErrNotExist) { + ctx.NotFound() + } else { + ctx.Error(http.StatusInternalServerError, "GetSystemOrDefaultWebhook", err) + } return } h, err := webhook_service.ToHook("/admin/", hook) @@ -160,7 +165,7 @@ func DeleteHook(ctx *context.APIContext) { hookID := ctx.ParamsInt64(":id") if err := webhook.DeleteDefaultSystemWebhook(ctx, hookID); err != nil { - if webhook.IsErrWebhookNotExist(err) { + if errors.Is(err, util.ErrNotExist) { ctx.NotFound() } else { ctx.Error(http.StatusInternalServerError, "DeleteDefaultSystemWebhook", err) |