From 6f4914aa7653638fcd4f1a6271c7ac487ac69cd3 Mon Sep 17 00:00:00 2001 From: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Date: Mon, 8 Jun 2026 11:09:18 +0530 Subject: [PATCH] Labeller action can remove labels from PR upon sync (#96131) ## About The Pull Request #92553 made it possible for the PR author to add labels to the PR body whenever it was updated however as discussed in the comments it was not possible to remove labels. Maintainers can still add/remove labels and that works as expected but the PR author could not. This obviously is inconvenient and should not be the case but now it is possible. This will not conflict with maintainer added/removed labels which means if the author says like removes the balance label from their changelog, but the maintainer adds the balance label then the balance label will always stay and cannot be removed by the author so labelling still works as intended. It will only remove labels added by the contributor should they decide to change their changelog/modified files/PR title at any point ## Changelog N/A --------- Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> --- tools/pull_request_hooks/autoLabel.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/pull_request_hooks/autoLabel.js b/tools/pull_request_hooks/autoLabel.js index b995bdc19d5..02ed25a2b6c 100644 --- a/tools/pull_request_hooks/autoLabel.js +++ b/tools/pull_request_hooks/autoLabel.js @@ -177,12 +177,11 @@ export async function get_updated_label_set({ github, context }) { const { body = "", diff_url, - labels = [], mergeable, title = "", } = pull_request; - const updated_labels = new Set(labels.map((l) => l.name)); + const updated_labels = new Set(); // Always check file diffs if (diff_url) { @@ -224,6 +223,9 @@ export async function get_updated_label_set({ github, context }) { } } catch (error) { console.error("Error fetching paginated events:", error); + for(const label of pull_request.labels){ + updated_labels.add(label.name); + } } // Always remove Test Merge Candidate