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:
1 parent
e26d08e666
commit
638645b8af
2 files changed
+21
-2
No files matched your search
@@ -21,8 +21,10 @@ export async function checkHumanActor(
|
|||||||
|
|
||||||
console.log(`Actor type: ${actorType}`);
|
console.log(`Actor type: ${actorType}`);
|
||||||
|
|
||||||
// Check bot permissions if actor is not a User
|
// On Forgejo, the user API doesn't return a `type` field (undefined).
|
||||||
if (actorType !== "User") {
|
// 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;
|
const allowedBots = githubContext.inputs.allowedBots;
|
||||||
|
|
||||||
// Check if all bots are allowed
|
// Check if all bots are allowed
|
||||||
|
|||||||
@@ -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.",
|
"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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user