fix(ci): GitHub App active-PR-limit exemption regression (#75311)

Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
This commit is contained in:
clawsweeper[bot]
2026-04-30 17:10:20 -07:00
committed by GitHub
parent 1ad50a36ac
commit e47a7448e9
2 changed files with 38 additions and 2 deletions

View File

@@ -808,12 +808,12 @@ async function removeLabels(github, context, issueNumber, labels, labelSet) {
issue_number: issueNumber,
name: label,
});
labelSet.delete(label);
} catch (error) {
if (error?.status !== 404) {
throw error;
}
}
labelSet.delete(label);
}
}

View File

@@ -105,11 +105,16 @@ function barnacleIssueContext(
function barnacleGithub(
files: ReturnType<typeof file>[],
options: { maintainerLogins?: string[]; repositoryRoles?: Record<string, string> } = {},
options: {
maintainerLogins?: string[];
removeLabelNotFound?: string[];
repositoryRoles?: Record<string, string>;
} = {},
) {
const maintainerLogins = new Set(
(options.maintainerLogins ?? []).map((login) => login.toLowerCase()),
);
const removeLabelNotFound = new Set(options.removeLabelNotFound ?? []);
const repositoryRoles = Object.fromEntries(
Object.entries(options.repositoryRoles ?? {}).map(([login, role]) => [
login.toLowerCase(),
@@ -147,6 +152,11 @@ function barnacleGithub(
},
removeLabel: async (params: { issue_number: number; name: string }) => {
calls.removeLabel.push(params);
if (removeLabelNotFound.has(params.name)) {
const error = new Error("not found") as Error & { status: number };
error.status = 404;
throw error;
}
},
update: async (params: { issue_number: number; state?: string }) => {
calls.update.push(params);
@@ -516,6 +526,32 @@ describe("barnacle-auto-response", () => {
expect(calls.update).toEqual([]);
});
it("does not close GitHub App-authored PRs when stale PR-limit label removal returns 404", async () => {
const { calls, github } = barnacleGithub([file("README.md")], {
removeLabelNotFound: ["r: too-many-prs"],
});
await runBarnacleAutoResponse({
github,
context: barnacleContext(
{
user: {
login: "renovate[bot]",
type: "Bot",
},
},
["r: too-many-prs"],
),
core: {
info: () => undefined,
},
});
expect(calls.removeLabel).toContainEqual(expect.objectContaining({ name: "r: too-many-prs" }));
expect(calls.createComment).toEqual([]);
expect(calls.update).toEqual([]);
});
it("still adds candidate labels to broad contributor PRs", async () => {
const { calls, github } = barnacleGithub([
file("ui/src/app.ts"),