fix(github): match bot actors in comment filters using GraphQL __typename (#1616)

`exclude_comments_by_actor` and `include_comments_by_actor` never matched
any bot. Both the documented `*[bot]` wildcard and exact entries such as
`dependabot[bot]` silently did nothing.

GitHub's GraphQL API returns the bare login for App actors ("dependabot"),
while REST and the GitHub UI append a suffix ("dependabot[bot]"). Filter
patterns are written in the suffixed form, so matching a GraphQL login
against them could never succeed and `actor.endsWith("[bot]")` was dead
code.

Request `__typename` on the Actor-typed author selections and normalize
App actors to their suffixed name via `resolveActorName()` before matching.
Normalizing at the filter boundary fixes the wildcard and exact-match cases
together, and leaves the author names shown in the prompt unchanged.

The existing test mocked `login: "scanner[bot]"`, a payload GraphQL never
produces, which is why the gap was invisible. It now mocks the real shape
(`__typename: "Bot", login: "scanner"`) and fails without this fix.

The commit author selection is left alone: it is a GitCommit, not an Actor.

Fixes #1514

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Neal Daftary
2026-08-18 17:24:26 -07:00
committed by GitHub
co-authored by Claude Opus 5
parent 0a80d21df7
commit 65b50df083
6 changed files with 93 additions and 5 deletions
+5
View File
@@ -3,9 +3,14 @@
// GitHub's GraphQL `author`/`actor` fields resolve to null when the underlying
// account has been deleted (the "ghost" user). Any field typed as
// `GitHubAuthor | null` can therefore be null at runtime and must be guarded.
// `__typename` distinguishes an App/bot actor from a human. GraphQL's
// `Actor.login` returns the bare name for bots ("dependabot"), unlike REST which
// appends a suffix ("dependabot[bot]"), so the typename is the only reliable bot
// signal on this data. See `resolveActorName` in `utils/actor-filter.ts`.
export type GitHubAuthor = {
login: string;
name?: string;
__typename?: string;
};
export type GitHubComment = {