[pytorchbot] bot manage "in progress" label - #8663
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
janeyx99
left a comment
There was a problem hiding this comment.
lgtm but someone from dev infra should confirm
| ); | ||
| const invalidLabels = labelsToAdd.filter( | ||
| (l: string) => !repoLabels.has(l) && !BOT_MANAGED_PR_LABELS.has(l) | ||
| ); |
There was a problem hiding this comment.
please consider narrowing the scope here.
🟡 Scope the `@pytorchbot label` refusal the way the webhook removal is scoped — to pull requests in pytorch/pytorch. (ai-generated section)
The pull_request.labeled handler deletes in progress only when isPyTorchPyTorch(owner, repo) holds, so the policy it enforces is pytorch/pytorch-only. handleLabel applies BOT_MANAGED_PR_LABELS with no repo check and no pull-request check, and pytorchBot.ts wires the command handler up for every installation — so on any other repo the bot serves, and on issues as well as pull requests, @pytorchbot label "in progress" now answers "managed automatically by pytorch-bot and cannot be added manually" while the GitHub UI still lets anyone add the same label there. The new test in torchci/test/labelCommands.test.ts runs against zhouzhuojie/gha-ci-playground and the refusal fires. Matching the webhook takes two conditions rather than one, and both are already to hand in handleLabel: isPyTorchPyTorch(this.owner, this.repo), and is_pr_comment unless blocking the label on issues is intended.
| }) | ||
| ); | ||
| return; | ||
| } |
There was a problem hiding this comment.
flagging this as a minor race condition.
⚪ Consider deciding on who last applied the label rather than on who sent the event being handled. (ai-generated section)
The guard reads context.payload.sender, the account named in the event currently being processed. GitHub redelivers a webhook when the handler errors, and delivery order is not guaranteed, so a replayed human labeled event can run after pytorch-bot has legitimately applied the label — at which point the handler deletes the bot's own label and comments that it "cannot be added manually". getBotAppliedLabels, a few hundred lines up in the same file, already answers "who last labelled this?" from the issue timeline and is used for exactly that purpose on the draft-gated removals.
do not let people add "in progress" label, remove this label if someone tries
this label should be managed by the bot only