From edfb5437a4f9fa16f84c8d863041d241ca71625f Mon Sep 17 00:00:00 2001 From: Chris Lloyd <718+chrislloyd@users.noreply.github.com> Date: Fri, 13 Feb 2026 15:40:00 -0800 Subject: [PATCH] Fix sweep script crashing on locked issues (#25649) The sweep job (https://github.com/anthropics/claude-code/actions/runs/21983111029/job/63510453226) was silently failing when closeExpired tried to comment on a locked issue, causing a 403 from the GitHub API. Two issues: 1. closeExpired didn't skip locked issues like markStale already does. Adding the same `if (issue.locked) continue` guard fixes this. 2. The error was swallowed by `main().catch(console.error)` which logs to stderr but exits 0, so CI reported success despite the crash. Replaced the main() wrapper with top-level await so unhandled errors properly crash the process with a non-zero exit code. ## Test plan YOLO --- scripts/sweep.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/sweep.ts b/scripts/sweep.ts index 8a67a458..2ebd5318 100644 --- a/scripts/sweep.ts +++ b/scripts/sweep.ts @@ -115,6 +115,7 @@ async function closeExpired(owner: string, repo: string) { for (const issue of issues) { if (issue.pull_request) continue; + if (issue.locked) continue; const base = `/repos/${owner}/${repo}/issues/${issue.number}`; const events = await githubRequest(`${base}/events?per_page=100`); @@ -144,20 +145,14 @@ async function closeExpired(owner: string, repo: string) { // -- -async function main() { - const owner = process.env.GITHUB_REPOSITORY_OWNER; - const repo = process.env.GITHUB_REPOSITORY_NAME; - if (!owner || !repo) - throw new Error("GITHUB_REPOSITORY_OWNER and GITHUB_REPOSITORY_NAME required"); +const owner = process.env.GITHUB_REPOSITORY_OWNER; +const repo = process.env.GITHUB_REPOSITORY_NAME; +if (!owner || !repo) + throw new Error("GITHUB_REPOSITORY_OWNER and GITHUB_REPOSITORY_NAME required"); - if (DRY_RUN) console.log("DRY RUN — no changes will be made\n"); +if (DRY_RUN) console.log("DRY RUN — no changes will be made\n"); - const labeled = await markStale(owner, repo); - const closed = await closeExpired(owner, repo); +const labeled = await markStale(owner, repo); +const closed = await closeExpired(owner, repo); - console.log(`\nDone: ${labeled} ${DRY_RUN ? "would be labeled" : "labeled"} stale, ${closed} ${DRY_RUN ? "would be closed" : "closed"}`); -} - -main().catch(console.error); - -export {}; +console.log(`\nDone: ${labeled} ${DRY_RUN ? "would be labeled" : "labeled"} stale, ${closed} ${DRY_RUN ? "would be closed" : "closed"}`);