-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System Hooks API confused with Default Hooks API #23139
Comments
CreateHook calls gitea/routers/api/v1/admin/hooks.go Line 112 in 10cdcb9
"AddSystemHook", which sounds like it should add a system hook gitea/routers/api/v1/utils/hook.go Lines 71 to 82 in 10cdcb9
but the object it creates is here gitea/routers/api/v1/utils/hook.go Lines 137 to 171 in 10cdcb9
which leaves The only place in the code that's set to gitea/routers/web/repo/webhook.go Lines 98 to 105 in 10cdcb9
gitea/routers/web/repo/webhook.go Lines 229 to 241 in 10cdcb9
|
Also there's no way to set a hook secret with the API, which makes it unusable (unless your hooks all disable signature verification). |
Fixes go-gitea#23139, hopefully. Also, allow creating/editing (but not viewing) the _secret_ associated with each hook.
…/admin/default-hooks This should better address the ambiguity that led to go-gitea#23139. Rename parts of the supporting module to match this naming convention.
Fixes go-gitea#23139, hopefully. Also, allow creating/editing (but not viewing) the _secret_ associated with each hook.
…/admin/default-hooks This should better address the ambiguity that led to go-gitea#23139. Rename parts of the supporting module to match this naming convention.
"System" webhooks -- webhooks run on all repos on a Gitea instance -- were added in go-gitea#14537 (I believe?) but managing them by the API is buggy. - In routers/api/v1/utils/hook.go, correctly handle the distinction between system and default webhooks. This enables actually creating, editing and deleting both kinds. - In routers/api/, move `/api/v1/admin/hooks` to `/api/v1/admin/hooks/{system,default}`. This allows users to access the code in the previous point. - In routers/web/, move `/admin/{system,default}-hooks` and most of `/admin/hooks/` into `/admin/hooks/{system,default}` to match API. - In model/, normalize vocabulary. Since the new sub-type, the terminology has been a confusing mix of "SystemWebhook", "DefaultSystemWebhook", "SystemOrDefaultWebhook" and "DefaultWebhook". Standardize on "AdminWebhook" everywhere with `isSystemWebhook bool` to separate the two sub-types. - Using a bool made it easier to handle both cases without duplicating the router endpoints - Make PATCH /admin/hooks/{system,default}/:id appropriately return 404. Fixes go-gitea#23139. Supersedes go-gitea#23142.
I ran into this. Thanks for working on it. Any idea how far this is from being complete? |
I think this can be closed as of #33180
- type: string
enum:
- system
- default
- all
description: system, default or both kinds of webhooks
name: type
default: system
in: query |
Description
GET /admin/hooks
lists hooks withis_system_webhook = true
, butPOST /admin/hooks
creates them without. There does not currently seem to be a way to create a system webhook from the API -- only default webhooks; meanwhile there is no way to list default webhooks from the API.I see that
/admin/hooks
was only added less than a month ago with #14537. It's an niche but extremely helpful feature for what I'm trying to do with Gitea, so I want to help get it working.Gitea Version
1.19.0+dev-586-g10cdcb9ea
Can you reproduce the bug on the Gitea demo site?
No -- but only because I don't have admin rights there
Log Gist
https://gist.github.com/kousu/1f0be0c81dce500caef0b0af3e985196
Screenshots
Under http://localhost:3000/admin/hooks I start with an empty slate
I go to http://localhost:3000/api/swagger and log in:
http://localhost:3000/api/swagger#/admin/adminGetHook gives an empty list
I create a hook:
Back on the UI at http://localhost:3000/admin/hooks I can see it, but it's a Default Hook:
But using the API gets me an empty list still:
If I make a system webhook with the UI
it adds to the UI
and the API can see it:
If I add another Default Webhook
The API cannot see it
...unless I specifically ask for hook 20
19 also works, but there's nothing to distinguish that it is a system hook:
Git Version
2.34.1
Operating System
Ubuntu 22.04
How are you running Gitea?
Database
SQLite
The text was updated successfully, but these errors were encountered: