Skip to content

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

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

Open
wolfaba opened this issue Jan 16, 2025 · 25 comments · 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 · 25 comments · Fixed by #33320
Assignees
Milestone

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
@dR3b
Copy link

dR3b commented Jan 20, 2025

I'm affected too. Please backport this fix as soon as possible. Thanks

@foxit64
Copy link

foxit64 commented Jan 23, 2025

I have the same problem! Gitea webhooks are send several times.

@wolfaba
Copy link
Author

wolfaba commented Jan 23, 2025

@lunny do you have any time plan for next release with the fix? Thank you.

@lunny lunny added this to the 1.23.2 milestone Jan 23, 2025
@lunny
Copy link
Member

lunny commented Jan 23, 2025

@lunny do you have any time plan for next release with the fix? Thank you.

This should be fixed in v1.23.2 I have sent a pull request #33320 and I hope it can be merged ASAP after that is merged I can release v1.23.2. The expectation date is outdated. 😢

@lunny
Copy link
Member

lunny commented Jan 30, 2025

I think you can work around this issue by selecting custom events and exclusively choosing the push event at the moment.

@wolfaba
Copy link
Author

wolfaba commented Jan 30, 2025

I have tried to select only push event and it still runs multiple webhooks.

@lunny
Copy link
Member

lunny commented Feb 3, 2025

#33442 should have fixed this problem.
#33320 will allow configuration status webhook in settings and fix the correct status webhook content.

@lunny lunny closed this as completed Feb 3, 2025
lunny added a commit that referenced this issue Feb 4, 2025
Fix #32873 
Fix #33201 
~Fix #33244~
~Fix #33302~

depends on ~#33396~

A part of this PR should be backported to v1.23 manually.
lunny added a commit to lunny/gitea that referenced this issue Feb 4, 2025
Fix go-gitea#32873
Fix go-gitea#33201
~Fix go-gitea#33244~
~Fix go-gitea#33302~

depends on ~go-gitea#33396~

A part of this PR should be backported to v1.23 manually.
lunny added a commit that referenced this issue Feb 5, 2025
@otbutz
Copy link

otbutz commented Feb 6, 2025

@lunny updated from 1.23.1 to 1.23.3 and was hit with a barrage of Commit Status changed webhook notifications:

Image

According to the settings of the webhook, commit status events shouldn't be active:

Image

@wxiaoguang wxiaoguang reopened this Feb 6, 2025
@otbutz
Copy link

otbutz commented Feb 6, 2025

Could this be something persistency related? There hasn't been any event after I edited the webhook settings. (basically a no-op):

Enable Statuses -> Apply -> Disable Statuses -> Apply

@wolfaba
Copy link
Author

wolfaba commented Feb 6, 2025

In our environment the version 1.23.3 is working fine now.

@balki
Copy link
Contributor

balki commented Feb 6, 2025

Same issue with a bunch of status messages and the telegram webhook went red due to 429 response.
My hook settings:

Hook type: telegram

Bot Token: XXXXXXXXXXXXX
Chat ID: ###########
Thread ID:

Trigger On:
Custom Events...
Repository Events
[✓] Create (Branch or tag created)

Branch filter: tag
[✓] Active


Example message:

{
  "text": "Commit Status changed: \u003ca href=\"/XXXXX/yyy/actions/runs/29/jobs/2\" rel=\"nofollow\"\u003e/ MacOS Go 1.23 (push)[dbe350a5859b98ef8e1d5aa65dc21ef150bff85e]:Waiting to run\u003c/a\u003e by \u003ca href=\"https://gitea.aaaa.bbb/gitea-actions\" rel=\"nofollow\"\u003egitea-actions\u003c/a\u003e",
  "parse_mode": "HTML",
  "disable_web_page_preview": true
}

Gitea version: 1.23.3 (archlinux)

@balki
Copy link
Contributor

balki commented Feb 7, 2025

Not just "Commit status" messages. Today got spammed with 'merge-requests created messages'. The hook is just supposed to notify on new tags created.

{
  "text": "[\u003ca href=\"https://gitea.aaaa.bb/XXXXX/YYYY\" rel=\"nofollow\"\u003eXXXXX/YYYY\u003c/a\u003e]  \u003ca href=\"https://gitea.aaaa.bbb/XXXXX/YYYY/src/refs/merge-requests/8779/merge\" rel=\"nofollow\"\u003erefs/merge-requests/8779/merge\u003c/a\u003e created",
  "parse_mode": "HTML",
  "disable_web_page_preview": true
}

@lunny
Copy link
Member

lunny commented Feb 10, 2025

Same issue with a bunch of status messages and the telegram webhook went red due to 429 response. My hook settings:

Hook type: telegram

Bot Token: XXXXXXXXXXXXX Chat ID: ########### Thread ID:

Trigger On: Custom Events... Repository Events [✓] Create (Branch or tag created)

Branch filter: tag [✓] Active

Example message:

{
"text": "Commit Status changed: \u003ca href="/XXXXX/yyy/actions/runs/29/jobs/2" rel="nofollow"\u003e/ MacOS Go 1.23 (push)[dbe350a5859b98ef8e1d5aa65dc21ef150bff85e]:Waiting to run\u003c/a\u003e by \u003ca href="https://gitea.aaaa.bbb/gitea-actions\" rel="nofollow"\u003egitea-actions\u003c/a\u003e",
"parse_mode": "HTML",
"disable_web_page_preview": true
}

Gitea version: 1.23.3 (archlinux)

Have you check your webhook configuration, whether it includes Statuses?

@lunny
Copy link
Member

lunny commented Feb 10, 2025

Please check if you have any other high-level webhooks configured to receive all events. I am unable to reproduce the issue on my end.

@ZantsuRocks
Copy link

I have 3 webhook and none of them send commit status. My discord server was flooded with commit status chances from CI in all three webhooks...

Gitea Version is 1.23.3 and as soon as i updated from 1.23.1 to 1.23.3 and started the service my discord began to popup the notifications.
The only way to stop was disabling all 3 webhooks.

Image

Image

Image

Image

@lunny
Copy link
Member

lunny commented Feb 10, 2025

I have 3 webhook and none of them send commit status. My discord server was flooded with commit status chances from CI in all three webhooks...

Gitea Version is 1.23.3 and as soon as i updated from 1.23.1 to 1.23.3 and started the service my discord began to popup the notifications. The only way to stop was disabling all 3 webhooks.

Image

Image

Image

Image

Can you enable statuses and disable statuses and active it to try again?

@lunny
Copy link
Member

lunny commented Feb 10, 2025

Can you also check the history of this webhook and check the event types on the http headers.

@ZantsuRocks
Copy link

ZantsuRocks commented Feb 10, 2025

Can you also check the history of this webhook and check the event types on the http headers.

One of the items:
Request:

Request URL: https://discord.com/api/webhooks/########################
Request method: POST
Content-Type: application/json
X-GitHub-Delivery: 08140e31-7b66-4bda-9e3f-76447c8866f0
X-GitHub-Event: status
X-GitHub-Event-Type: status
X-Gitea-Delivery: 08140e31-7b66-4bda-9e3f-76447c8866f0
X-Gitea-Event: status
X-Gitea-Event-Type: status
X-Gitea-Signature: 
X-Gogs-Delivery: 08140e31-7b66-4bda-9e3f-76447c8866f0
X-Gogs-Event: status
X-Gogs-Event-Type: status
X-Gogs-Signature: 
X-Hub-Signature: sha1=
X-Hub-Signature-256: sha256=

Content:

{
  "wait": false,
  "content": "",
  "username": "Lançamento de Versões",
  "avatar_url": "https://static-00.iconduck.com/assets.00/gitea-icon-512x512-8lvcua7z.png",
  "tts": false,
  "embeds": [
    {
      "title": "Commit Status changed: continuous-integration/drone/push[6318b2c2a6b71473da43d8baa7dbe0d66f1e0a28]:Build is running",
      "description": "",
      "url": "https://MY-CI-DOMAIN/AGST/AirSense/79",
      "color": 1754624,
      "footer": {
        "text": ""
      },
      "author": {
        "name": "wagner.rebello",
        "url": "https://MY-DOMAIN/wagner.rebello",
        "icon_url": "https://MY-DOMAIN/avatars/53171ee2606976be490df98ed8780cf2fb51e1c6527ebbbcdc7958d017b26cf7"
      },
      "fields": null
    }
  ]
}

I will try to reenable the hooks tomorrow with status enabled, and disabled again.

@otbutz
Copy link

otbutz commented Feb 11, 2025

@lunny this has to be something related to persistency and/or database migrations.

Enable Statuses -> Apply -> Disable Statuses -> Apply

Not a single false notification since.

@ZantsuRocks
Copy link

After enabling and disabling the statuses it seems that the hook works as intended.

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.

10 participants