Commit 080065a
authored
fix(review): guard recordPrOutcome's webhook path against double-counting (#10346)
recordPrOutcome (the inbound pull_request.closed webhook path) always incremented
loopover_pr_outcomes_total and wrote a pr_outcome row, with no existence check.
recordTerminalActionOutcome (the bot's own direct-action path) already probes for
an existing pr_outcome row and skips both the metric increment and the write when
one exists.
In the realistic production ordering the direct write lands first (right after the
merge/close mutation), then GitHub delivers the closed webhook for the same action,
so the counter was incremented twice for one real PR outcome. The duplicate ROW is
harmless (every downstream reader takes the LATEST row per target), but the counter
had no such defense.
Mirror recordTerminalActionOutcome's guard exactly: probe for an existing pr_outcome
row before incrementing or writing, and return early when one exists. A probe-read
failure logs and proceeds (fail-open) so a genuinely-new outcome is never dropped.
No other decision logic in recordPrOutcome changes.
Closes #103321 parent c353e9d commit 080065a
2 files changed
Lines changed: 60 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
432 | 451 | | |
433 | 452 | | |
434 | 453 | | |
435 | | - | |
436 | 454 | | |
437 | 455 | | |
438 | 456 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
270 | 311 | | |
271 | 312 | | |
272 | 313 | | |
| |||
0 commit comments