Webhook label_updated contains no labels when using the web interface #14528

Closed
opened 2025-11-02 11:15:21 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @kim2048 on GitHub (May 28, 2025).

Description

Hello,
I have an issue with 2 labels A and B (A is exclusive but I don't think that matters). When I remove B via the web interface, then I get a label_updated webhook json with an empty labels array.
When I do this via the api with DELETE /repos/{owner}/{repo}/issues/{index}/labels/{id} I get a correct labels array with A in it.

Gitea Version

1.23.8

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

I don't know

Database

None

Originally created by @kim2048 on GitHub (May 28, 2025). ### Description Hello, I have an issue with 2 labels `A` and `B` (`A` is exclusive but I don't think that matters). When I remove `B` via the web interface, then I get a `label_updated` webhook json with an empty `labels` array. When I do this via the api with `DELETE /repos/{owner}/{repo}/issues/{index}/labels/{id}` I get a correct `labels` array with `A` in it. ### Gitea Version 1.23.8 ### Can you reproduce the bug on the Gitea demo site? No ### Log Gist _No response_ ### Screenshots _No response_ ### Git Version _No response_ ### Operating System _No response_ ### How are you running Gitea? I don't know ### Database None
GiteaMirror added the topic/webhookstype/bug labels 2025-11-02 11:15:21 -06:00
Author
Owner

@badhezi commented on GitHub (Jun 1, 2025):

it appears also the API returns empty response when deleting a label from an issue.
https://github.com/badhezi/gitea/blob/main/routers/api/v1/repo/issue_label.go#L196

	if err := issue_service.RemoveLabel(ctx, issue, ctx.Doer, label); err != nil {
		ctx.APIErrorInternal(err)
		return
	}

	ctx.Status(http.StatusNoContent)

can you show an example where DELETE /repos/{owner}/{repo}/issues/{index}/labels/{id} returns a list of current labels after the deletion?
anyhow it's seems like this is not implemented, AFAIK.
I can implement that if needed, github's API does that.

edit: I see what you mean, when triggering a delete from API the webhook payload does include the labels. looking into that

@badhezi commented on GitHub (Jun 1, 2025): it appears also the API returns empty response when deleting a label from an issue. https://github.com/badhezi/gitea/blob/main/routers/api/v1/repo/issue_label.go#L196 ``` if err := issue_service.RemoveLabel(ctx, issue, ctx.Doer, label); err != nil { ctx.APIErrorInternal(err) return } ctx.Status(http.StatusNoContent) ``` can you show an example where `DELETE /repos/{owner}/{repo}/issues/{index}/labels/{id}` returns a list of current labels after the deletion? anyhow it's seems like this is not implemented, AFAIK. I can implement that if needed, [github's API does that.](https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#remove-a-label-from-an-issue) edit: I see what you mean, when triggering a delete from API the webhook payload does include the labels. looking into that
Author
Owner

@badhezi commented on GitHub (Jun 1, 2025):

Found the issue
when removing an issue label from web, this function is first being called
bb6377d080/routers/web/repo/issue.go (L184)
which calls issue.LoadAttributes(ctx), that sets issue.isLabelsLoaded = true

this prevents this function bb6377d080/models/issues/issue_label.go (L203)
from loading the updated labels after the deletion of the requested labels, resulting in the webhook returning labels = nil

this flow is not triggered with calling from API as there is no need to render the issue labels for the user prior to the request.

@badhezi commented on GitHub (Jun 1, 2025): Found the issue when removing an issue label from web, this function is first being called https://github.com/go-gitea/gitea/blob/bb6377d0807e56586a94a1f14a5ffa7da7155865/routers/web/repo/issue.go#L184 which calls `issue.LoadAttributes(ctx)`, that sets `issue.isLabelsLoaded = true` this prevents this function https://github.com/go-gitea/gitea/blob/bb6377d0807e56586a94a1f14a5ffa7da7155865/models/issues/issue_label.go#L203 from loading the updated labels after the deletion of the requested labels, resulting in the webhook returning `labels = nil` this flow is not triggered with calling from API as there is no need to render the issue labels for the user prior to the request.
Author
Owner

@kim2048 commented on GitHub (Jun 2, 2025):

Sorry, was on vacation. Glad to see you've found something :)

@kim2048 commented on GitHub (Jun 2, 2025): Sorry, was on vacation. Glad to see you've found something :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#14528