Skip to content

Webhook sends wrong PR state #10660

@cedrichopf

Description

@cedrichopf
  • Gitea version (or commit ref): 1.11.1 built with GNU Make 4.2.1, go1.13.8
  • Git version: 2.24.1
  • Operating system: Docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist: not relevant

Description

I am currently working on a Webhook Event System which should do a specific action every time the labels on a PR have been updated. Currently, it looks like the Webhook configured for the repository is always sending the previous state of the PR to the Webhook endpoint.
So in the example below, I have a PR with the label "bug" assigned, after I've added the label "help wanted", the body of the Webhook only contains the label "bug". If I update the PR again, e.g. adding another label called "feature", the body of the Webhook contains the labels "bug" and "help wanted" (always the previous state before adding or removing a label).

...
"labels": [
      {
        "id": 8,
        "name": "bug",
        "color": "ee0701",
        "description": "Something is not working",
        "url": ""
      }
    ],
...

Screenshots

none

How to reproduce

  1. Create a small Go application which handles the Webhook and prints out the Webhook body:
package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

func main() {
	router := gin.Default()
	router.POST("/pull-request", func(c *gin.Context) {
		buf := make([]byte, 1024)
		num, _ := c.Request.Body.Read(buf)
		reqBody := string(buf[0:num])
		fmt.Println(reqBody)
		c.String(200, "OK")
	})
	router.Run(":80")
}
  1. Create a repository and add the endpoint of your running Go application as a Webhook of type "Gitea" to the repository webhooks (e.g. http://localhost:80/pull-request) and configure the Webhook to trigger on the custom event Pull Request.
  2. Create a PR to the repository.
  3. Add one or more labels to the PR and check the output in the Go application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue/confirmedIssue has been reviewed and confirmed to be present or accepted to be implementedtype/bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions