Files
claude-code-action/src/github/api/queries/github.ts
T
65b50df083 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 <[email protected]>
2026-08-18 17:24:26 -07:00

154 lines
2.9 KiB
TypeScript

// GraphQL queries for GitHub data
export const PR_QUERY = `
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
title
body
author {
__typename
login
}
baseRefName
headRefName
headRefOid
isCrossRepository
headRepository {
owner {
login
}
name
}
createdAt
updatedAt
lastEditedAt
additions
deletions
state
labels(first: 100) {
nodes {
name
}
}
commits(first: 100) {
totalCount
nodes {
commit {
oid
message
author {
name
email
}
}
}
}
files(first: 100) {
nodes {
path
additions
deletions
changeType
}
}
comments(first: 100) {
nodes {
id
databaseId
body
author {
__typename
login
}
createdAt
updatedAt
lastEditedAt
isMinimized
}
}
reviews(first: 100) {
nodes {
id
databaseId
author {
__typename
login
}
body
state
submittedAt
updatedAt
lastEditedAt
comments(first: 100) {
nodes {
id
databaseId
body
path
line
diffHunk
author {
__typename
login
}
createdAt
updatedAt
lastEditedAt
isMinimized
}
}
}
}
}
}
}
`;
export const ISSUE_QUERY = `
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $number) {
title
body
author {
__typename
login
}
createdAt
updatedAt
lastEditedAt
state
labels(first: 100) {
nodes {
name
}
}
comments(first: 100) {
nodes {
id
databaseId
body
author {
__typename
login
}
createdAt
updatedAt
lastEditedAt
isMinimized
}
}
}
}
}
`;
export const USER_QUERY = `
query($login: String!) {
user(login: $login) {
name
}
}
`;