-
Notifications
You must be signed in to change notification settings - Fork 769
Description
Hi,
Some context: we are using the Hub4j GitHub API for our Quarkus Bot (it's a GitHub App based on Quarkus and running as a GraalVM native executable).
The bot can automatically add labels based on triage rules but we started seeing concurrency issues when someone adds labels when the bot is also adding some. Believe it or not, this happened in real life.
AFAICS, the issue is that the GHIssue#addLabels() method doesn't really add the labels but set them. My understanding is that it should use this method: https://docs.github.com/en/rest/reference/issues#add-labels-to-an-issue and that's not what is done here:
github-api/src/main/java/org/kohsuke/github/GHIssue.java
Lines 362 to 374 in 6d86cfb
| private void _addLabels(Collection<String> names) throws IOException { | |
| List<String> newLabels = new ArrayList<String>(); | |
| for (GHLabel label : getLabels()) { | |
| newLabels.add(label.getName()); | |
| } | |
| for (String name : names) { | |
| if (!newLabels.contains(name)) { | |
| newLabels.add(name); | |
| } | |
| } | |
| setLabels(newLabels.toArray(new String[0])); | |
| } |
The issue occurs when a label is added manually in the UI between the call at line 365 and the call at line 373: the labels added in the UI are lost, which is very unfortunate given they are critical to our workflow. You can see an example of this issue here: quarkusio/quarkus#15402 (comment) - Georgios added the triage/backport? label in the UI and the bot removed it while our bot is only adding labels.
Does it make any sense? Any chance this could be fixed?
Thanks!