Skip to content

agentHost: cover GraphQL mutation roots and null merge permission - #331719

Merged
Benjamin Christopher Simmonds (benibenj) merged 2 commits into
mainfrom
benibenj/agents/graphql-mutation-root-test-coverage
Aug 20, 2026
Merged

agentHost: cover GraphQL mutation roots and null merge permission#331719
Benjamin Christopher Simmonds (benibenj) merged 2 commits into
mainfrom
benibenj/agents/graphql-mutation-root-test-coverage

Conversation

@benibenj

Copy link
Copy Markdown
Contributor

Follow-up to #331712, addressing two review comments that arrived after auto-merge had already landed that PR.

The mutation fix had no regression coverage

The existing mutation tests only match operation names and variables, so reintroducing the invalid root-level rateLimit selection would still have passed. That is precisely why the original bug survived.

ProgrammableGitHubServer now rejects any mutation that selects a Query-root-only field at the mutation root. Putting the check in the fake server rather than in per-test assertions means every current and future mutation test enforces it automatically, with no opt-in required.

Verified by temporarily reintroducing the bug — it now fails with a direct diagnostic instead of silently passing:

GraphQL mutation selected rateLimit on the Mutation root, which GitHub only exposes on Query

The root-field parser handles aliases (pullRequest: __type(...)), arguments containing braces (orderBy: { field: UPDATED_AT }), and nested selections, so a nested rateLimit is correctly ignored.

The permission test only covered READ

viewerPermission is null under GitHub App authentication, which deliberately disables Agent Merge. That fail-closed path could previously have regressed independently of the ordinary read-only case.

The test now snapshots the whole RepositoryPermission range including null, in a single assertion:

{ ADMIN: true, MAINTAIN: true, WRITE: true, TRIAGE: false, READ: false, null: false }

Verification

  • All 92 platform/github tests pass against current main
  • typecheck-client and eslint clean
  • Test-only change; no production code touched

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds regression coverage for Agent Merge GraphQL mutations and repository merge permissions.

Changes:

  • Validates mutation root selections against query-only fields.
  • Tests all repository permission values, including null.
Show a summary per file
File Description
pullRequestQueryService.test.ts Expands merge-permission coverage.
programmableGitHubServer.ts Adds mutation-root validation.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread src/vs/platform/github/test/node/programmableGitHubServer.ts Outdated
Comment thread src/vs/platform/github/test/node/pullRequestQueryService.test.ts Outdated
The mutation fix had no regression coverage: the existing tests only match
operation names and variables, so reintroducing the invalid root-level
rateLimit selection still passed. That is why the bug survived.

ProgrammableGitHubServer now rejects any mutation that selects a Query-root-only
field at the mutation root. Placing the check in the fake server rather than in
individual assertions means every current and future mutation test enforces it
automatically. Verified by reintroducing the bug, which now fails two tests with
a direct diagnostic.

The permission test also only covered a READ viewer. It now snapshots the whole
RepositoryPermission range including null, the GitHub App case that deliberately
disables Agent Merge, so the fail-closed path cannot regress on its own.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The mutation-root guard only recognized documents whose first token was
mutation, so a leading fragment definition or a multi-operation document
bypassed it entirely. It also scanned every top-level selection set, so a
sibling query selecting rateLimit failed an otherwise valid mutation.

The guard now parses the document into operations, resolves the one selected
by operationName (or the sole operation when the document is unambiguous), and
inspects only that operation's root selection set. Parsing blanks comments and
string literals first so braces inside them cannot skew matching, and skips
variable definitions and inline fragment headers.

ProgrammableGitHubServer tests now cover both regressions plus aliases, nested
selections and string arguments. Verified they fail against the previous
implementation in both directions: the fragment-prefixed mutation goes
undetected, and the valid mutation beside a rateLimit query is wrongly rejected.

The permission test folded its discriminant check into the recorded value, so a
non-mergeability result collapsed to false and silently matched the TRIAGE,
READ and null cases. It now asserts the fragment before snapshotting.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@benibenj
Benjamin Christopher Simmonds (benibenj) force-pushed the benibenj/agents/graphql-mutation-root-test-coverage branch from 9836bfd to 9153125 Compare August 20, 2026 09:08
@benibenj
Benjamin Christopher Simmonds (benibenj) merged commit 97ed7b5 into main Aug 20, 2026
29 of 51 checks passed
@benibenj
Benjamin Christopher Simmonds (benibenj) deleted the benibenj/agents/graphql-mutation-root-test-coverage branch August 20, 2026 09:33
@vs-code-engineering vs-code-engineering Bot added this to the 1.135.0 milestone Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants