Skip to content

Commit 5f5b2c4

Browse files
committed
fix(issues): harden area-label apply path after CodeRabbit review
Fix streaming truncat stem matching, only addLabels for labels ensureLabel confirmed available, and document issues:write on the backfill job.
1 parent 20401d3 commit 5f5b2c4

3 files changed

Lines changed: 31 additions & 16 deletions

File tree

.github/scripts/issue-quality.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ const AREA_HEURISTICS = [
399399
{
400400
label: "streaming",
401401
scope: "full",
402-
re: /\b(sse|websocket|\bws\b|stream(ing)?\b.{0,40}\b(truncat|terminal)|terminal (sse )?frame|without a terminal)\b/i,
402+
re: /\b(sse|websocket|\bws\b|stream(ing)?\b.{0,40}\btruncat\w*|stream(ing)?\b.{0,40}\bterminal\b|terminal (sse )?frame|without a terminal)\b/i,
403403
},
404404
{
405405
label: "tools",

.github/scripts/issue-quality.test.cjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,4 +1792,13 @@ describe("detectAreaLabels", () => {
17921792
});
17931793
assert.ok(labels.includes("account-pool"), `got ${labels.join(",")}`);
17941794
});
1795+
1796+
it("matches truncated streaming wording via truncat stem", () => {
1797+
const labels = detectAreaLabels({
1798+
title: "Upstream streaming response truncated mid-turn",
1799+
body: ["### Area", "Other", "### Summary", "The streaming response was truncated."].join("\n"),
1800+
labels: ["bug"],
1801+
});
1802+
assert.ok(labels.includes("streaming"), `got ${labels.join(",")}`);
1803+
});
17951804
});

.github/workflows/enforce-issue-quality.yml

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -917,26 +917,28 @@ jobs:
917917
async function ensureLabel(name) {
918918
try {
919919
await github.rest.issues.getLabel({ owner, repo, name });
920-
return;
920+
return true;
921921
} catch (err) {
922922
if (err.status !== 404) {
923923
core.warning(`Failed to look up label "${name}": ${err.message || err}`);
924-
return;
924+
return false;
925925
}
926926
}
927927
const meta = AREA_LABELS[name];
928-
if (!meta) return;
928+
if (!meta) return false;
929929
try {
930930
await github.rest.issues.createLabel({
931931
owner, repo, name, color: meta.color, description: meta.description,
932932
});
933933
core.info(`Created label "${name}".`);
934+
return true;
934935
} catch (err) {
935936
if (err.status === 422) {
936937
core.info(`Label "${name}" appeared concurrently; continuing.`);
937-
return;
938+
return true;
938939
}
939940
core.warning(`Failed to create label "${name}": ${err.message || err}`);
941+
return false;
940942
}
941943
}
942944
@@ -946,9 +948,9 @@ jobs:
946948
heuristicBody: areaHeuristicBody,
947949
labels,
948950
});
949-
const areaLabelsToAdd = areaLabels.filter((name) => !labels.includes(name));
950-
for (const name of areaLabelsToAdd) {
951-
await ensureLabel(name);
951+
const areaLabelsToAdd = [];
952+
for (const name of areaLabels.filter((candidate) => !labels.includes(candidate))) {
953+
if (await ensureLabel(name)) areaLabelsToAdd.push(name);
952954
}
953955
if (areaLabelsToAdd.length > 0) {
954956
try {
@@ -1132,7 +1134,9 @@ jobs:
11321134
if: github.event_name == 'workflow_dispatch' && inputs.backfill_open_areas == true
11331135
runs-on: ubuntu-latest
11341136
permissions:
1137+
# Read-only checkout of trusted scripts from the default branch.
11351138
contents: read
1139+
# Required to list open issues, create missing area labels, and apply them.
11361140
issues: write
11371141
steps:
11381142
- name: Checkout trusted workflow code
@@ -1182,23 +1186,25 @@ jobs:
11821186
async function ensureLabel(name) {
11831187
try {
11841188
await github.rest.issues.getLabel({ owner, repo, name });
1185-
return;
1189+
return true;
11861190
} catch (err) {
11871191
if (err.status !== 404) {
11881192
core.warning(`Failed to look up label "${name}": ${err.message || err}`);
1189-
return;
1193+
return false;
11901194
}
11911195
}
11921196
const meta = AREA_LABELS[name];
1193-
if (!meta) return;
1197+
if (!meta) return false;
11941198
try {
11951199
await github.rest.issues.createLabel({
11961200
owner, repo, name, color: meta.color, description: meta.description,
11971201
});
11981202
core.info(`Created label "${name}".`);
1203+
return true;
11991204
} catch (err) {
1200-
if (err.status === 422) return;
1205+
if (err.status === 422) return true;
12011206
core.warning(`Failed to create label "${name}": ${err.message || err}`);
1207+
return false;
12021208
}
12031209
}
12041210
@@ -1229,11 +1235,11 @@ jobs:
12291235
heuristicBody: areaHeuristicBody,
12301236
labels,
12311237
});
1232-
const toAdd = areaLabels.filter((name) => !labels.includes(name));
1233-
if (toAdd.length === 0) continue;
1234-
for (const name of toAdd) {
1235-
await ensureLabel(name);
1238+
const toAdd = [];
1239+
for (const name of areaLabels.filter((candidate) => !labels.includes(candidate))) {
1240+
if (await ensureLabel(name)) toAdd.push(name);
12361241
}
1242+
if (toAdd.length === 0) continue;
12371243
try {
12381244
await github.rest.issues.addLabels({
12391245
owner,

0 commit comments

Comments
 (0)