Skip to content

System Hooks API confused with Default Hooks API #23139

Closed
@kousu

Description

@kousu

Description

GET /admin/hooks lists hooks with is_system_webhook = true, but POST /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

Screenshot 2023-02-25 at 01-27-23 Gitea Git with a cup of tea

I go to http://localhost:3000/api/swagger and log in:

Screenshot 2023-02-25 at 01-26-31 Gitea API

http://localhost:3000/api/swagger#/admin/adminGetHook gives an empty list

Screenshot 2023-02-25 at 01-30-46 Gitea API

I create a hook:

Screenshot 2023-02-25 at 01-30-26 Gitea API

Back on the UI at http://localhost:3000/admin/hooks I can see it, but it's a Default Hook:

Screenshot 2023-02-25 at 01-31-25 Gitea Git with a cup of tea

But using the API gets me an empty list still:

Screenshot 2023-02-25 at 01-32-07 Gitea API

If I make a system webhook with the UI

Screenshot 2023-02-25 at 01-33-16 Gitea Git with a cup of tea

it adds to the UI

Screenshot 2023-02-25 at 01-33-31 Gitea Git with a cup of tea

and the API can see it:

Screenshot 2023-02-25 at 01-33-59 Gitea API

If I add another Default Webhook

Screenshot 2023-02-25 at 01-34-33 Gitea Git with a cup of tea

The API cannot see it

Screenshot 2023-02-25 at 01-34-58 Gitea API

...unless I specifically ask for hook 20

Screenshot 2023-02-25 at 01-35-44 Gitea API

19 also works, but there's nothing to distinguish that it is a system hook:

Screenshot 2023-02-25 at 01-36-12 Gitea API

Git Version

2.34.1

Operating System

Ubuntu 22.04

How are you running Gitea?

user@dev:~/src/gitea$ TAGS="bindata sqlite sqlite_unlock_notify" make build
user@dev:~/src/gitea$ ./gitea

Database

SQLite

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions