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

Webhook sends wrong PR state #10660

Closed
2 of 7 tasks
cedrichopf opened this issue Mar 7, 2020 · 3 comments · Fixed by #13007
Closed
2 of 7 tasks

Webhook sends wrong PR state #10660

cedrichopf opened this issue Mar 7, 2020 · 3 comments · Fixed by #13007
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug

Comments

@cedrichopf
Copy link

  • 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.
@stale
Copy link

stale bot commented May 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale stale bot added the issue/stale label May 7, 2020
@stale
Copy link

stale bot commented May 21, 2020

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale stale bot closed this as completed May 21, 2020
@cedrichopf
Copy link
Author

Still relevant

@jolheiser jolheiser reopened this Sep 17, 2020
@stale stale bot removed the issue/stale label Sep 17, 2020
@jolheiser jolheiser added the issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented label Sep 17, 2020
zeripath added a commit to zeripath/gitea that referenced this issue Oct 1, 2020
(Re)Load issue labels when labels are added or removed

This means that the label state that the webhooks produce accurately matches
the changes that they are reporting.

Fix go-gitea#10660

Signed-off-by: Andrew Thornton <art27@cantab.net>
lafriks pushed a commit that referenced this issue Oct 5, 2020
(Re)Load issue labels when labels are added or removed

This means that the label state that the webhooks produce accurately matches
the changes that they are reporting.

Fix #10660

Signed-off-by: Andrew Thornton <art27@cantab.net>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants