Skip to content
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

Gitea submits webhooks on "status" event, even if webhook is defined only for "push" #33302

Open
wolfaba opened this issue Jan 16, 2025 · 5 comments · May be fixed by #33320
Open

Gitea submits webhooks on "status" event, even if webhook is defined only for "push" #33302

wolfaba opened this issue Jan 16, 2025 · 5 comments · May be fixed by #33320

Comments

@wolfaba
Copy link

wolfaba commented Jan 16, 2025

Description

Dear gitea developers,
we have a few webhooks in our gitea repositories. We have one webhook to jenkins generic trigger and other webhook to woodpecker. Webhook to jenkins should be called only for push events, webhook to woodpecker should be called for custom events (create, push and pull request events).
After update from gitea 1.22.6 to 1.23.1, gitea started trigger jenkins job 7 times instead one.
In gitea webhook config we can really see seven POST webhook requests to jenkins and to woodpecker. But woodpecker starts just one job, maybe because woodpecker filter the webhook requests and process only those from "push" events. But jenkins just start new job for every webhook trigger.
I have found that after gitea triggers the webhook on woodpecker, the woodpecker requests "status" on gitea. Gitea starts then webhooks again for this "status" request, even the trigger should happen only for push events.
If I disable woodpecker webhook, gitea sends no webhook to woodpecker, woodpecker does not request "status" on gitea, which means, gitea sends only one webhook request to jenkins for the "push" event.
I have activated debug log in gitea, but I am not sure if there is something important. I can see

git/commit_status.go:480:NewCommitStatus() [D] NewCommitStatus[/var/lib/gitea/gitea/data/repositories/ORG/REPO, HASH]: 1
git/commit_status.go:480:NewCommitStatus() [D] NewCommitStatus[/var/lib/gitea/gitea/data/repositories/ORG/REPO, HASH]: 2
git/commit_status.go:480:NewCommitStatus() [D] NewCommitStatus[/var/lib/gitea/gitea/data/repositories/ORG/REPO, HASH]: 3
git/commit_status.go:480:NewCommitStatus() [D] NewCommitStatus[/var/lib/gitea/gitea/data/repositories/ORG/REPO, HASH]: 4
git/commit_status.go:480:NewCommitStatus() [D] NewCommitStatus[/var/lib/gitea/gitea/data/repositories/ORG/REPO, HASH]: 5

and then webhook_sender queue processing

queue/workergroup.go:161:func1() [D] Queue "webhook_sender" starts new worker
eb/routing/logger.go:102:func1() [I] router: completed GET /ORG/REPO/info/refs?service=git-upload-pack for 10.0.42.125:0, 401 Unauthorized in 2.2ms @ repo/githttp.go:518(repo.GetInfoRefs)
dules/git/command.go:291:Run() [D] git.Command.RunDir(/var/lib/gitea/gitea/data/repositories/ORG/REPO): /usr/bin/git -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= upload-pack --stateless-rpc --advertise-refs .
eb/routing/logger.go:102:func1() [I] router: completed GET /ORG/REPO/info/refs?service=git-upload-pack for 10.0.42.125:0, 200 OK in 8.6ms @ repo/githttp.go:518(repo.GetInfoRefs)
dules/git/command.go:291:Run() [D] git.Command.RunDir(/var/lib/gitea/gitea/data/repositories/ORG/REPO): /usr/bin/git -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= upload-pack --stateless-rpc /var/lib/gitea/gitea/data/repositories/ORG/REPO
eb/routing/logger.go:102:func1() [I] router: completed POST /ORG/REPO/git-upload-pack for 10.0.42.125:0, 200 OK in 11.7ms @ repo/githttp.go:478(repo.ServiceUploadPack)
eb/routing/logger.go:102:func1() [I] router: completed GET /ORG/REPO/info/refs?service=git-upload-pack for 10.0.42.125:0, 401 Unauthorized in 1.6ms @ repo/githttp.go:518(repo.GetInfoRefs)
dules/git/command.go:291:Run() [D] git.Command.RunDir(/var/lib/gitea/gitea/data/repositories/ORG/REPO): /usr/bin/git -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= upload-pack --stateless-rpc --advertise-refs .
eb/routing/logger.go:102:func1() [I] router: completed GET /ORG/REPO/info/refs?service=git-upload-pack for 10.0.42.125:0, 200 OK in 6.8ms @ repo/githttp.go:518(repo.GetInfoRefs)
dules/git/command.go:291:Run() [D] git.Command.RunDir(/var/lib/gitea/gitea/data/repositories/ORG/REPO): /usr/bin/git -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= upload-pack --stateless-rpc /var/lib/gitea/gitea/data/repositories/ORG/REPO
eb/routing/logger.go:102:func1() [I] router: completed POST /ORG/REPO/git-upload-pack for 10.0.42.125:0, 200 OK in 18.8ms @ repo/githttp.go:478(repo.ServiceUploadPack)
eb/routing/logger.go:102:func1() [I] router: completed GET /ORG/REPO/info/refs?service=git-upload-pack for 10.0.42.125:0, 401 Unauthorized in 1.7ms @ repo/githttp.go:518(repo.GetInfoRefs)
dules/git/command.go:291:Run() [D] git.Command.RunDir(/var/lib/gitea/gitea/data/repositories/ORG/REPO): /usr/bin/git -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= upload-pack --stateless-rpc --advertise-refs .
eb/routing/logger.go:102:func1() [I] router: completed GET /ORG/REPO/info/refs?service=git-upload-pack for 10.0.42.125:0, 200 OK in 6.3ms @ repo/githttp.go:518(repo.GetInfoRefs)
dules/git/command.go:291:Run() [D] git.Command.RunDir(/var/lib/gitea/gitea/data/repositories/ORG/REPO): /usr/bin/git -c protocol.version=2 -c credential.helper= -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= upload-pack --stateless-rpc /var/lib/gitea/gitea/data/repositories/ORG/REPO
eb/routing/logger.go:102:func1() [I] router: completed POST /ORG/REPO/git-upload-pack for 10.0.42.125:0, 200 OK in 255.7ms @ repo/githttp.go:478(repo.ServiceUploadPack)
queue/workergroup.go:195:func1() [D] Queue "webhook_sender" stops idle worker

Could you please verify if the webhook trigger filter works correctly and for "Push events" trigger really only on "push" events and not on "status" events?

Thank you very much checking and eventually fixing.

Regards,

Robert Wolf.

Gitea Version

1.23.1

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

git version 2.30.2

Operating System

Debian 11.11 Linux

How are you running Gitea?

We use released gitea version, starting from systemd on Debian 11.11 Linux

Gitea version 1.23.1 built with GNU Make 4.3, go1.23.4 : bindata, sqlite, sqlite_unlock_notify

Database

PostgreSQL

@wolfaba
Copy link
Author

wolfaba commented Jan 16, 2025

btw, I have tried to search, but have not found the same problem already reported

@wxiaoguang
Copy link
Contributor

Maybe the "status" webhook is related to Add new event commit status creation and webhook implementation #27151

@lunny

@lunny
Copy link
Member

lunny commented Jan 16, 2025

I will investigate it and could you confirm whether you created a webhook with only a push event in Gitea?

@wolfaba
Copy link
Author

wolfaba commented Jan 17, 2025

yes, for Jenkins, we have "Trigger on: Push events", see the attached screenshot
Image

@m-erhardt
Copy link

m-erhardt commented Jan 17, 2025

I'm affected by this as well. Judging by the JSON payload of the webhook I would guess this relates to Gitea Actions CI jobs...

My webhook is configured to only run on Push events on the master-branch.

The context-element of the JSON request bodys corresponds to the names of my CI jobs in the repo and the description-elements is either Waiting to run or Successful in [x]s

{
  "commit": {
    "id": "411acbb5098d2257592f94bfa1bbf121cb61df78",
    [...]
  },
  "context": "Name of CI job",
  "created_at": "2025-01-17T08:50:30Z",
  "description": "Successful in 1m17s",
  [...]
}

So it seems the webhook gets fired twice per CI job. One with "description": "Waiting to run" and one with "description": "Successful in ...s"

@lunny lunny self-assigned this Jan 18, 2025
@lunny lunny linked a pull request Jan 18, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants