Skip to content

Commit 5296881

Browse files
FredKSchottFred K. Schott
andauthored
auto-triage: improve issue labeling (#15493)
* fix bad labeling logic * fix bad labeling logic * add gitbot token * Update issue-triage.ts * Change label formatting from bold to quotes --------- Co-authored-by: Fred K. Schott <fschott@cloudflare.com>
1 parent 6c60b05 commit 5296881

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

.flue/workflows/issue-triage.ts

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,10 @@ const fixResultSchema = v.object({
3232
});
3333

3434
const labelResultSchema = v.object({
35-
priority: v.pipe(
36-
v.nullable(v.string()),
37-
v.description(
38-
'Exactly one priority label name (e.g. "P4: important"), or null if unable to determine priority',
39-
),
40-
),
41-
packages: v.pipe(
35+
labels: v.pipe(
4236
v.array(v.string()),
4337
v.description(
44-
'One or more package label names (e.g. ["pkg: astro", "pkg: react"]). Empty array if unable to determine package.',
38+
'The labels to apply to the issue (e.g. ["- P1: chore", "pkg: react"]). Array must contain one "priority" label.',
4539
),
4640
),
4741
});
@@ -143,7 +137,7 @@ Return only "yes" or "no" inside the ---RESULT_START--- / ---RESULT_END--- block
143137

144138
await flue.shell(`gh issue comment ${issueNumber} --body-file -`, {
145139
stdin: comment,
146-
env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN },
140+
env: { GH_TOKEN: flue.secrets.FREDKBOT_GITHUB_TOKEN },
147141
});
148142

149143
if (reproduceResult.reproducible) {
@@ -163,34 +157,31 @@ Return only "yes" or "no" inside the ---RESULT_START--- / ---RESULT_END--- block
163157
.map((line) => JSON.parse(line) as { name: string; description: string });
164158

165159
// Filter to priority labels (P followed by a digit) and package labels (pkg: prefix)
166-
const priorityLabels = allLabels.filter((l) => /^P\d/.test(l.name));
160+
const priorityLabels = allLabels.filter((l) => /^- P\d/.test(l.name));
167161
const packageLabels = allLabels.filter((l) => l.name.startsWith('pkg:'));
168-
const candidateLabels = [...priorityLabels, ...packageLabels];
169162

170163
const labelResult = await flue.prompt(
171164
`Label the following GitHub issue based on our Triage Report which summarizes what we learned in our attempt to reproduce, diagnose, and fix the issue.
172165
173166
Select the most appropriate labels from the list below. Use the label descriptions to guide your decision, combined with the triage report's cause and impact analysis.
174167
175168
### Rules
176-
- Select exactly ONE priority label based on the severity and impact of the bug. Pay close attention to the "Cause" and "Impact" sections of the triage report.
177-
- You must select ONE priorty label! If you are not sure, just use your best judgement based on the label descriptions and the findings of the triage report.
169+
- Select exactly ONE priority label based on the label description and the severity and impact of the bug. Pay close attention to the "Cause" and "Impact" sections of the triage report.
170+
- You must select ONE priority label! If you are not sure, just use your best judgement based on the label descriptions and the findings of the triage report.
178171
- Select 0-3 package labels based on where where the issue lives (or most likely lives) in the monorepo. The triage report's diagnosis should make it clear. If you cannot confidently determine the affected package(s), return an empty array for packages.
179172
- Return the exact label names as they appear above — do not modify them.
180173
181174
### Priority Labels (select exactly one)
182-
${priorityLabels.map((l) => `- **${l.name}**: ${l.description || '(no description)'}`).join('\n')}
175+
${priorityLabels.map((l) => `- "${l.name}": ${l.description || '(no description)'}`).join('\n')}
183176
184177
### Package Labels (select zero or more)
185-
${packageLabels.map((l) => `- **${l.name}**: ${l.description || '(no description)'}`).join('\n')}
178+
${packageLabels.map((l) => `- "${l.name}": ${l.description || '(no description)'}`).join('\n')}
186179
187180
---
188181
189-
<issue format="md">
190-
# ${issue.title}
191-
192-
${issue.body}
193-
</issue>
182+
<github-issue format="json">
183+
${issueJson}
184+
</github-issue>
194185
195186
<triage-report format="md">
196187
${comment}
@@ -199,13 +190,10 @@ ${comment}
199190
{ result: labelResultSchema },
200191
);
201192

202-
const labelsToAdd = [
203-
...(labelResult.priority ? [labelResult.priority] : []),
204-
...labelResult.packages,
205-
].filter((name) => candidateLabels.some((l) => l.name === name));
206-
207-
if (labelsToAdd.length > 0) {
208-
const labelFlags = labelsToAdd.map((l) => `--add-label ${JSON.stringify(l)}`).join(' ');
193+
if (labelResult.labels.length > 0) {
194+
const labelFlags = labelResult.labels
195+
.map((l) => `--add-label ${JSON.stringify(l)}`)
196+
.join(' ');
209197
await flue.shell(`gh issue edit ${issueNumber} ${labelFlags}`, {
210198
env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN },
211199
});
@@ -218,13 +206,8 @@ ${comment}
218206
env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN },
219207
});
220208
} else {
221-
// Not reproducible: add "needs repro" and remove "needs triage".
222-
// We handle both labels here (instead of just adding "needs repro") to avoid
223-
// the issue-labeled.yml workflow posting a duplicate auto-comment.
224-
await flue.shell(
225-
`gh issue edit ${issueNumber} --add-label "needs repro" --remove-label "needs triage"`,
226-
{ env: { GH_TOKEN: flue.secrets.GITHUB_TOKEN } },
227-
);
209+
// Not reproducible: do nothing. The "needs triage" label stays on the issue
210+
// so that it can continue to be worked on and triaged by the humans.
228211
}
229212
return { reproduceResult, diagnoseResult, fixResult, isPushed };
230213
}

.github/workflows/issue-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
- name: Run workflow
8585
env:
8686
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
FREDKBOT_GITHUB_TOKEN: ${{ secrets.FREDKBOT_GITHUB_TOKEN }}
8788
ANTHROPIC_API_KEY: ${{ secrets.CI_ANTHROPIC_API_KEY }}
8889
ISSUE_NUMBER: ${{ github.event.issue.number }}
8990
run: |

0 commit comments

Comments
 (0)