From 3a6a6f6682f20ebf32b0dcdbd410785f712fd5b7 Mon Sep 17 00:00:00 2001 From: Iulia Bejan <64602043+iulia-b@users.noreply.github.com> Date: Wed, 22 Apr 2026 17:42:25 +0300 Subject: [PATCH] Fix set_issue_fields mutation: use correct inline fragments for IssueFieldValue union (#2366) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix set_issue_fields mutation: use correct inline fragments for IssueFieldValue 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) * Update test mock to match corrected inline fragments * Update handler_test.go formatting --- pkg/github/granular_tools_test.go | 11 ++++++++++- pkg/github/issues_granular.go | 11 ++++++++++- pkg/http/handler_test.go | 24 ++++++++++++------------ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/pkg/github/granular_tools_test.go b/pkg/github/granular_tools_test.go index 883158bb25..6623894e43 100644 --- a/pkg/github/granular_tools_test.go +++ b/pkg/github/granular_tools_test.go @@ -810,9 +810,18 @@ func TestGranularSetIssueFields(t *testing.T) { URL githubv4.String } 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"` } } `graphql:"setIssueFieldValue(input: $input)"` }{}, diff --git a/pkg/github/issues_granular.go b/pkg/github/issues_granular.go index 5dbd7d8d11..fe3b4bcc9b 100644 --- a/pkg/github/issues_granular.go +++ b/pkg/github/issues_granular.go @@ -793,9 +793,18 @@ func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.Serv URL githubv4.String } 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"` } } `graphql:"setIssueFieldValue(input: $input)"` } diff --git a/pkg/http/handler_test.go b/pkg/http/handler_test.go index 46e86b4a89..002266ba15 100644 --- a/pkg/http/handler_test.go +++ b/pkg/http/handler_test.go @@ -639,33 +639,33 @@ func TestStaticConfigEnforcement(t *testing.T) { // and rejects requests with "application/json; charset=utf-8". func TestContentTypeHandling(t *testing.T) { tests := []struct { - name string - contentType string + name string + contentType string expectUnsupportedMedia bool }{ { - name: "exact application/json is accepted", - contentType: "application/json", + name: "exact application/json is accepted", + contentType: "application/json", expectUnsupportedMedia: false, }, { - name: "application/json with charset=utf-8 should be accepted", - contentType: "application/json; charset=utf-8", + name: "application/json with charset=utf-8 should be accepted", + contentType: "application/json; charset=utf-8", expectUnsupportedMedia: false, }, { - name: "application/json with charset=UTF-8 should be accepted", - contentType: "application/json; charset=UTF-8", + name: "application/json with charset=UTF-8 should be accepted", + contentType: "application/json; charset=UTF-8", expectUnsupportedMedia: false, }, { - name: "completely wrong content type is rejected", - contentType: "text/plain", + name: "completely wrong content type is rejected", + contentType: "text/plain", expectUnsupportedMedia: true, }, { - name: "empty content type is rejected", - contentType: "", + name: "empty content type is rejected", + contentType: "", expectUnsupportedMedia: true, }, }