missing headers in status webhook #13978

Closed
opened 2025-11-02 10:59:00 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @JonasB2497 on GitHub (Jan 13, 2025).

Description

I am using Gitea in combination with Jenkins and the Gitea Plugin for Jenkins.
Using a webhook for all events in the gitea organization and and organization folder on the Jenkins side.

The new status webhook (#27151) introduced in 1.23.0 has the X-GitHub-Event, X-Gitea-Event and X-Gogs-Event headers missing/empty:

Request URL: http://jenkins:8080/gitea-webhook/post
Request method: POST
Content-Type: application/json
X-GitHub-Delivery: e862f2f7-cf9e-4903-8f95-5c67f51ac3bc
X-GitHub-Event: 
X-GitHub-Event-Type: status
X-Gitea-Delivery: e862f2f7-cf9e-4903-8f95-5c67f51ac3bc
X-Gitea-Event: 
X-Gitea-Event-Type: status
X-Gitea-Signature: 
X-Gogs-Delivery: e862f2f7-cf9e-4903-8f95-5c67f51ac3bc
X-Gogs-Event: 
X-Gogs-Event-Type: status
X-Gogs-Signature: 
X-Hub-Signature: sha1=
X-Hub-Signature-256: sha256=

In comparison a webhook for a push event:

Request URL: http://jenkins:8080/gitea-webhook/post
Request method: POST
Content-Type: application/json
X-GitHub-Delivery: b0ced20b-1aaf-4f8d-9529-ad00ebd9210d
X-GitHub-Event: push
X-GitHub-Event-Type: push
X-Gitea-Delivery: b0ced20b-1aaf-4f8d-9529-ad00ebd9210d
X-Gitea-Event: push
X-Gitea-Event-Type: push
X-Gitea-Signature: 
X-Gogs-Delivery: b0ced20b-1aaf-4f8d-9529-ad00ebd9210d
X-Gogs-Event: push
X-Gogs-Event-Type: push
X-Gogs-Signature: 
X-Hub-Signature: sha1=
X-Hub-Signature-256: sha256=

Because of this the Jenkins plugin returns an error code with the log message:

java.lang.Exception: Expecting a Gitea event, missing expected X-Gitea-Event header

I think this should be ultimately be made more robust in the plugin but is probably a bug here as well.

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

2.47.1

Operating System

Debian 12

How are you running Gitea?

using gitea/gitea:latest docker image

Database

MySQL/MariaDB

Originally created by @JonasB2497 on GitHub (Jan 13, 2025). ### Description I am using Gitea in combination with Jenkins and the Gitea Plugin for Jenkins. Using a webhook for all events in the gitea organization and and organization folder on the Jenkins side. The new status webhook (#27151) introduced in 1.23.0 has the `X-GitHub-Event`, `X-Gitea-Event` and `X-Gogs-Event` headers missing/empty: ``` Request URL: http://jenkins:8080/gitea-webhook/post Request method: POST Content-Type: application/json X-GitHub-Delivery: e862f2f7-cf9e-4903-8f95-5c67f51ac3bc X-GitHub-Event: X-GitHub-Event-Type: status X-Gitea-Delivery: e862f2f7-cf9e-4903-8f95-5c67f51ac3bc X-Gitea-Event: X-Gitea-Event-Type: status X-Gitea-Signature: X-Gogs-Delivery: e862f2f7-cf9e-4903-8f95-5c67f51ac3bc X-Gogs-Event: X-Gogs-Event-Type: status X-Gogs-Signature: X-Hub-Signature: sha1= X-Hub-Signature-256: sha256= ``` In comparison a webhook for a push event: ``` Request URL: http://jenkins:8080/gitea-webhook/post Request method: POST Content-Type: application/json X-GitHub-Delivery: b0ced20b-1aaf-4f8d-9529-ad00ebd9210d X-GitHub-Event: push X-GitHub-Event-Type: push X-Gitea-Delivery: b0ced20b-1aaf-4f8d-9529-ad00ebd9210d X-Gitea-Event: push X-Gitea-Event-Type: push X-Gitea-Signature: X-Gogs-Delivery: b0ced20b-1aaf-4f8d-9529-ad00ebd9210d X-Gogs-Event: push X-Gogs-Event-Type: push X-Gogs-Signature: X-Hub-Signature: sha1= X-Hub-Signature-256: sha256= ``` Because of this the Jenkins plugin returns an error code with the log message: ``` java.lang.Exception: Expecting a Gitea event, missing expected X-Gitea-Event header ``` I think this should be ultimately be made more robust in the plugin but is probably a bug here as well. ### 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 2.47.1 ### Operating System Debian 12 ### How are you running Gitea? using `gitea/gitea:latest` docker image ### Database MySQL/MariaDB
GiteaMirror added the topic/webhookstype/bug labels 2025-11-02 10:59:01 -06:00
Author
Owner

@yp05327 commented on GitHub (Jan 14, 2025):

I tried it in my local with the main branch, it seems that there's no problems.
image
Are there any possible way to reproduce it?

@yp05327 commented on GitHub (Jan 14, 2025): I tried it in my local with the main branch, it seems that there's no problems. ![image](https://github.com/user-attachments/assets/e8d42593-9c73-485a-9a5a-320b9b2fa283) Are there any possible way to reproduce it?
Author
Owner

@JonasB2497 commented on GitHub (Jan 14, 2025):

push webhooks work for me as well. The issue currently only occurs with status webhooks (have tested push, create, pull_request and status webhooks with version 1.23.1). All except the status webhook have the headers set (with different values of course).
My workflow looks something like this:

sequenceDiagram
User->>Gitea: commit
Gitea->>Jenkins: push-webhook
Jenkins->>Gitea: status update: building
Gitea->>Jenkins: status-webhook
Note right of Jenkins: Here the error occurs because of the missing header

Based on that you will need something like this to trigger the status webhook without Jenkins:

curl --user [USER] --request POST -H "Content-Type: application/json" --data '{"context": "string", "description": "string", "state": "success", "target_url": "string"}' http://[GITEA_HOST]:3000/api/v1/repos/{owner}/{repo}/statuses/{sha}

For me this command creates the (in my view) malformed webhook:

Screenshot 2025-01-14 at 11-45-51 Update Webhook - Gitea Git with a cup of tea

@JonasB2497 commented on GitHub (Jan 14, 2025): `push` webhooks work for me as well. The issue currently only occurs with `status` webhooks (have tested `push`, `create`, `pull_request` and `status` webhooks with version 1.23.1). All except the `status` webhook have the headers set (with different values of course). My workflow looks something like this: ```mermaid sequenceDiagram User->>Gitea: commit Gitea->>Jenkins: push-webhook Jenkins->>Gitea: status update: building Gitea->>Jenkins: status-webhook Note right of Jenkins: Here the error occurs because of the missing header ``` Based on that you will need something like this to trigger the `status` webhook without Jenkins: ``` curl --user [USER] --request POST -H "Content-Type: application/json" --data '{"context": "string", "description": "string", "state": "success", "target_url": "string"}' http://[GITEA_HOST]:3000/api/v1/repos/{owner}/{repo}/statuses/{sha} ``` For me this command creates the (in my view) malformed webhook: ![Screenshot 2025-01-14 at 11-45-51 Update Webhook - Gitea Git with a cup of tea](https://github.com/user-attachments/assets/306ff97f-45cb-42d3-acc2-6a2e5fb963d4)
Author
Owner

@lunny commented on GitHub (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 commented on GitHub (Feb 3, 2025): #33442 should have fixed this problem. #33320 will allow configuration status webhook in settings and fix the correct status webhook content.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#13978