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

missing headers in status webhook #33244

Open
JonasB2497 opened this issue Jan 13, 2025 · 2 comments
Open

missing headers in status webhook #33244

JonasB2497 opened this issue Jan 13, 2025 · 2 comments

Comments

@JonasB2497
Copy link

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

@JonasB2497 JonasB2497 changed the title Status Webhook missing headers in status webhook Jan 13, 2025
@yp05327
Copy link
Contributor

yp05327 commented 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?

@JonasB2497
Copy link
Author

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
Loading

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants