Skip to content

Fix set_issue_fields mutation: use correct inline fragments for IssueFieldValue union#2366

Merged
mattdholloway merged 3 commits intogithub:mainfrom
iulia-b:fix-set-issue-fields-mutation
Apr 22, 2026
Merged

Fix set_issue_fields mutation: use correct inline fragments for IssueFieldValue union#2366
mattdholloway merged 3 commits intogithub:mainfrom
iulia-b:fix-set-issue-fields-mutation

Conversation

@iulia-b
Copy link
Copy Markdown
Contributor

@iulia-b iulia-b commented Apr 22, 2026

Summary

Fix the set_issue_fields MCP tool's GraphQL mutation: calls failed with:

Field 'name' doesn't exist on type 'IssueFieldDateValue'

Root Cause

The mutation response struct used a single inline fragment ... on IssueFieldDateValue with a Name field, but IssueFieldDateValue doesn't have a name field — only IssueFieldSingleSelectValue does.

Since GraphQL validates the entire document (including response selection sets) before executing any operation, the invalid fragment caused GraphQL to reject the entire request. The mutation never fired at all — no fields were ever set, regardless of input.

Fix

Replace the single broken inline fragment with correct fragments for all four IssueFieldValue union types:

  • IssueFieldTextValuevalue
  • IssueFieldSingleSelectValuename
  • IssueFieldDateValuevalue
  • IssueFieldNumberValuevalue

The response still uses MinimalResponse (issue ID + URL), so the additional fragments are purely for GraphQL validation correctness and future-proofing.

Testing

  • All existing unit tests pass
  • Updated test mock to match the corrected mutation struct

iulia-b added 3 commits April 22, 2026 17:13
…FieldValue union

The mutation response struct used a single inline fragment
'... on IssueFieldDateValue' with a 'Name' field that doesn't exist
on that type (only IssueFieldSingleSelectValue has 'name'). This
caused GraphQL validation to fail with:

  Field 'name' doesn't exist on type 'IssueFieldDateValue'

Since GraphQL validates the entire document (including response
selection sets) before executing any operation, the mutation never
fired at all — no fields were ever set regardless of input.

Fix by adding correct inline fragments for all four union types:
- IssueFieldTextValue (value)
- IssueFieldSingleSelectValue (name)
- IssueFieldDateValue (value)
- IssueFieldNumberValue (value)
@iulia-b iulia-b marked this pull request as ready for review April 22, 2026 14:24
Copilot AI review requested due to automatic review settings April 22, 2026 14:24
@iulia-b iulia-b requested a review from a team as a code owner April 22, 2026 14:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the set_issue_fields granular MCP tool’s GraphQL mutation selection set so it uses valid inline fragments for the IssueFieldValue union, preventing GraphQL from rejecting the request at validation time.

Changes:

  • Updated the setIssueFieldValue mutation response struct to use correct inline fragments for all supported IssueFieldValue union members.
  • Updated the corresponding GraphQL mock matcher in unit tests to reflect the corrected selection set.
  • Minor formatting alignment in an HTTP handler test table.
Show a summary per file
File Description
pkg/github/issues_granular.go Fixes mutation response selection set by adding correct union inline fragments for issue field values.
pkg/github/granular_tools_test.go Updates mocked mutation matcher struct to match the new inline fragments.
pkg/http/handler_test.go Formatting-only alignment in the Content-Type handling test.

Copilot's findings

  • Files reviewed: 2/3 changed files
  • Comments generated: 1

Comment on lines 795 to 808
IssueFieldValues []struct {
Field struct {
TextValue struct {
Value string
} `graphql:"... on IssueFieldTextValue"`
SingleSelectValue struct {
Name string
} `graphql:"... on IssueFieldSingleSelectValue"`
DateValue struct {
Value string
} `graphql:"... on IssueFieldDateValue"`
NumberValue struct {
Value float64
} `graphql:"... on IssueFieldNumberValue"`
}
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

IssueFieldValues is requested in the mutation response but never read (the tool only marshals MinimalResponse from Issue). Consider removing IssueFieldValues from the selection set to reduce response payload and avoid having to maintain inline fragments for union validation; if you want to keep it, add a short comment explaining why it's intentionally unused.

Copilot uses AI. Check for mistakes.
@mattdholloway mattdholloway merged commit 3a6a6f6 into github:main Apr 22, 2026
16 checks passed
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