Commit 3417f41
authored
Dr. CI: only treat pytorch-bot's own comment as the Dr. CI comment (#8163)
## Problem
Dr. CI keeps a single status comment per PR and finds "its" comment
purely by scanning for the literal `<!-- drci-comment-start -->` marker,
with **no author check**. Two selectors do this and neither filters by
author:
- `getDrciComment()` (probot/webhook path, `lib/drciUtils.ts`) —
`listComments`, returns the first comment whose body includes the
marker.
- `getExistingDrCiComments()` (15-minute updater,
`pages/api/drci/drci.ts`) — ClickHouse `issue_comment` `body like '%<!--
drci-comment-start -->%'`, with no `ORDER BY`, fed into `new Map()`
(last row wins on duplicates).
If any other comment on the PR embeds that marker (e.g. a bot/tool that
quotes or forwards the Dr. CI status block), Dr. CI mistakes it for its
own and overwrites it in place.
Observed on #186611: a comment authored under a non-bot account embedded
the marker and was repeatedly overwritten with Dr. CI's render, while
the real `pytorch-bot[bot]` comment went stale.
## Fix
Require the comment author to be `pytorch-bot[bot]` in both selectors.
Dr. CI always creates/updates its comment through the pytorch-bot GitHub
App installation, so its author login is always `pytorch-bot[bot]` — in
the API handler the user token is only used for rate-limit identity; the
actual mutation uses `getOctokit(org, repo)` (the app installation). So
the guard doesn't affect the normal create/update flow.
Also adds `order by id desc` to the ClickHouse query so selection stays
deterministic (keeps the oldest bot comment, matching the
chronologically-first match `getDrciComment` returns) in the unlikely
event multiple bot-authored marker comments ever exist.
## Test plan
- New regression test in `drciBot.test.ts`: a marker-bearing comment
from a non-bot author is ignored and Dr. CI posts its own comment
instead.
- Updated the existing `drciBot.test.ts` fixtures to set the comment
author to `pytorch-bot[bot]`.
- `yarn jest test/drciBot.test.ts test/drci.test.ts` → both suites pass.
- Verified the updated ClickHouse query against prod for #186611:
without the author filter it returns 2 marker comments
(`pytorch-bot[bot]` + the impostor); with the filter it returns exactly
the `pytorch-bot[bot]` comment.1 parent a30fc53 commit 3417f41
3 files changed
Lines changed: 66 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
29 | 35 | | |
30 | 36 | | |
31 | 37 | | |
| |||
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
124 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
125 | 134 | | |
126 | 135 | | |
127 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
| 560 | + | |
559 | 561 | | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
560 | 567 | | |
561 | 568 | | |
562 | 569 | | |
563 | 570 | | |
| 571 | + | |
564 | 572 | | |
565 | 573 | | |
566 | 574 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| |||
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
127 | 174 | | |
128 | 175 | | |
129 | 176 | | |
| |||
221 | 268 | | |
222 | 269 | | |
223 | 270 | | |
| 271 | + | |
224 | 272 | | |
225 | 273 | | |
226 | 274 | | |
| |||
0 commit comments