fix(prd-1): handle undefined actor type on Forgejo

Forgejo's user API doesn't return a `type` field (GitHub returns
"User" or "Bot"). The undefined type was incorrectly treated as
non-human, blocking all Forgejo workflows. Now treat undefined/empty
type as human — Forgejo doesn't have GitHub-style bot accounts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vlad MocanuandClaude Opus 4.6 committed 2026-02-25 18:41:14 +02:00
1 parent e26d08e666
commit 638645b8af
2 files changed
+21 -2

No files matched your search

+4 -2
View File
@@ -21,8 +21,10 @@ export async function checkHumanActor(
console.log(`Actor type: ${actorType}`);
// Check bot permissions if actor is not a User
if (actorType !== "User") {
// On Forgejo, the user API doesn't return a `type` field (undefined).
// Treat undefined/empty type as a human user — Forgejo doesn't have
// GitHub-style bot/app accounts.
if (actorType && actorType !== "User") {
const allowedBots = githubContext.inputs.allowedBots;
// Check if all bots are allowed
+17
View File
@@ -93,4 +93,21 @@ describe("checkHumanActor", () => {
"Workflow initiated by non-human actor: other-bot (type: Bot). Add bot to allowed_bots list or use '*' to allow all bots.",
);
});
test("should treat undefined actor type as human (Forgejo compatibility)", async () => {
// Forgejo's user API doesn't return a `type` field
const mockOctokit = {
users: {
getByUsername: async () => ({
data: {},
}),
},
} as unknown as Octokit;
const context = createMockContext();
context.actor = "forgejo-user";
await expect(
checkHumanActor(mockOctokit, context),
).resolves.toBeUndefined();
});
});