Skip to content

Commit f235863

Browse files
committed
fix: handle 404 in checkHumanActor for bot/app actors
Bot actors like github-merge-queue[bot] can't be looked up via GET /users/{login} — the API returns 404. Previously this crashed the action before it could check the allowed_bots list. Now catches 404 and treats the actor as a Bot, allowing the existing allowedBots logic to decide whether to proceed. Made-with: Cursor
1 parent 65f29cf commit f235863

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

src/github/validation/actor.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,25 @@ export async function checkHumanActor(
1212
octokit: Octokit,
1313
githubContext: GitHubContext,
1414
) {
15-
// Fetch user information from GitHub API
16-
const { data: userData } = await octokit.users.getByUsername({
17-
username: githubContext.actor,
18-
});
15+
let actorType: string;
1916

20-
const actorType = userData.type;
17+
try {
18+
const { data: userData } = await octokit.users.getByUsername({
19+
username: githubContext.actor,
20+
});
21+
actorType = userData.type;
22+
} catch (error: any) {
23+
if (error.status === 404) {
24+
// Bot/app actors (e.g. github-merge-queue[bot]) can't be looked up
25+
// via the Users API — treat as a bot and fall through to allowedBots check
26+
console.log(
27+
`Actor "${githubContext.actor}" not found via Users API (likely a bot/app), treating as Bot`,
28+
);
29+
actorType = "Bot";
30+
} else {
31+
throw error;
32+
}
33+
}
2134

2235
console.log(`Actor type: ${actorType}`);
2336

0 commit comments

Comments
 (0)