From 638645b8afdd54e76ea90e11b06f0a22a59280b4 Mon Sep 17 00:00:00 2001 From: Vlad Mocanu Date: Wed, 25 Feb 2026 18:41:14 +0200 Subject: [PATCH] fix(prd-1): handle undefined actor type on Forgejo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/github/validation/actor.ts | 6 ++++-- test/actor.test.ts | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/github/validation/actor.ts b/src/github/validation/actor.ts index 36be2ff..be00168 100644 --- a/src/github/validation/actor.ts +++ b/src/github/validation/actor.ts @@ -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 diff --git a/test/actor.test.ts b/test/actor.test.ts index 4c9d206..613fdac 100644 --- a/test/actor.test.ts +++ b/test/actor.test.ts @@ -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(); + }); });