fix(issue-triage): only count a duplicate notice posted by the workflow itself

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
ryan 2026-09-19 01:15:27 +00:00
parent 2d3ae5a780
commit a25fdf52d3
3 changed files with 16 additions and 4 deletions

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bun
import { FLAG_LABEL, githubApi, listAll, type Comment, type GitHubApi } from "./auto-close-duplicates";
import { CLEAR_LABEL, readConfig, type FlagConfig as DispatchConfig } from "./flag-duplicate-issue";
import { CLEAR_LABEL, readConfig, WORKFLOW_LOGIN, type FlagConfig as DispatchConfig } from "./flag-duplicate-issue";
import { labelName } from "./issue-labels";
declare const process: { readonly env: Readonly<Record<string, string | undefined>> };
@ -31,7 +31,6 @@ export type DispatchVerdict =
export const BUG_LABEL = labelName("kind", "bug");
export const RUNNING_LABEL = labelName("repro", "running");
export const DISPATCH_MARKER = "<!-- litellm:repro-dispatched -->";
export const DISPATCH_AUTHOR = "github-actions[bot]";
export const DISPATCH_COMMENT = [
DISPATCH_MARKER,
"Devin is going to try to reproduce this. A PR or a Linear ticket follows if it does. Add repro:skip to opt out",
@ -71,7 +70,7 @@ export function dispatchTarget(
if (blocking.length > 0) {
return skip(`carries ${blocking.join(", ")}`);
}
if (comments.some((comment) => comment.user.login === DISPATCH_AUTHOR && comment.body.includes(DISPATCH_MARKER))) {
if (comments.some((comment) => comment.user.login === WORKFLOW_LOGIN && comment.body.includes(DISPATCH_MARKER))) {
return skip("was already dispatched once");
}
const pulls = openPullsReferencing(timeline);

View file

@ -204,6 +204,18 @@ describe("flagIssue", () => {
expect(rerun.writes).toEqual([]);
});
test("a notice marker pasted by a commenter is not a notice", async () => {
const pasted: Comment = {
id: 2,
body: "<!-- litellm:potential-duplicate candidates=10, --> looks like #10 to me",
created_at: "2026-09-10T00:00:00Z",
user: { type: "User", login: "someone" },
};
const { api, writes } = fakeApi(undefined, [pasted]);
expect((await flagIssue(api, config, verdict({ duplicate_of: null }))).kind).toBe("clear");
expect(writes).toEqual([`POST /repos/BerriAI/litellm/issues/35/labels {"labels":["${CLEAR_LABEL}"]}`]);
});
test("a failed comment leaves no marker, so the rerun finishes the job", async () => {
const commentsPath = "/repos/BerriAI/litellm/issues/35/comments";
const first = fakeApi(undefined, [], [commentsPath]);

View file

@ -41,6 +41,7 @@ export type FlagVerdict =
export const MIN_CONFIDENCE = 0.95;
export const NOTICE_MARKER_PREFIX = "<!-- litellm:potential-duplicate candidates=";
export const WORKFLOW_LOGIN = "github-actions[bot]";
export const CLEAR_LABEL = labelName("dup", "clear");
const skip = (reason: string): { readonly kind: "skip"; readonly reason: string } => ({ kind: "skip", reason });
@ -104,7 +105,7 @@ export async function flagIssue(api: GitHubApi, config: FlagConfig, verdict: Ver
const target = flagTarget(verdict, config.issueNumber);
const issuePath = `/repos/${config.repo}/issues/${config.issueNumber}`;
const comments = await listAll<Comment>(api, `${issuePath}/comments`);
if (comments.some((comment) => comment.body.includes(NOTICE_MARKER_PREFIX))) {
if (comments.some((comment) => comment.user.login === WORKFLOW_LOGIN && comment.body.includes(NOTICE_MARKER_PREFIX))) {
return skip("already carries a duplicate notice");
}
if (target.kind === "clear") {