Skip to content

Commit 3a6a6f6

Browse files
authored
Fix set_issue_fields mutation: use correct inline fragments for IssueFieldValue union (#2366)
* 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
1 parent f363fd0 commit 3a6a6f6

3 files changed

Lines changed: 32 additions & 14 deletions

File tree

pkg/github/granular_tools_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,9 +810,18 @@ func TestGranularSetIssueFields(t *testing.T) {
810810
URL githubv4.String
811811
}
812812
IssueFieldValues []struct {
813-
Field struct {
813+
TextValue struct {
814+
Value string
815+
} `graphql:"... on IssueFieldTextValue"`
816+
SingleSelectValue struct {
814817
Name string
818+
} `graphql:"... on IssueFieldSingleSelectValue"`
819+
DateValue struct {
820+
Value string
815821
} `graphql:"... on IssueFieldDateValue"`
822+
NumberValue struct {
823+
Value float64
824+
} `graphql:"... on IssueFieldNumberValue"`
816825
}
817826
} `graphql:"setIssueFieldValue(input: $input)"`
818827
}{},

pkg/github/issues_granular.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,18 @@ func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.Serv
793793
URL githubv4.String
794794
}
795795
IssueFieldValues []struct {
796-
Field struct {
796+
TextValue struct {
797+
Value string
798+
} `graphql:"... on IssueFieldTextValue"`
799+
SingleSelectValue struct {
797800
Name string
801+
} `graphql:"... on IssueFieldSingleSelectValue"`
802+
DateValue struct {
803+
Value string
798804
} `graphql:"... on IssueFieldDateValue"`
805+
NumberValue struct {
806+
Value float64
807+
} `graphql:"... on IssueFieldNumberValue"`
799808
}
800809
} `graphql:"setIssueFieldValue(input: $input)"`
801810
}

pkg/http/handler_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -639,33 +639,33 @@ func TestStaticConfigEnforcement(t *testing.T) {
639639
// and rejects requests with "application/json; charset=utf-8".
640640
func TestContentTypeHandling(t *testing.T) {
641641
tests := []struct {
642-
name string
643-
contentType string
642+
name string
643+
contentType string
644644
expectUnsupportedMedia bool
645645
}{
646646
{
647-
name: "exact application/json is accepted",
648-
contentType: "application/json",
647+
name: "exact application/json is accepted",
648+
contentType: "application/json",
649649
expectUnsupportedMedia: false,
650650
},
651651
{
652-
name: "application/json with charset=utf-8 should be accepted",
653-
contentType: "application/json; charset=utf-8",
652+
name: "application/json with charset=utf-8 should be accepted",
653+
contentType: "application/json; charset=utf-8",
654654
expectUnsupportedMedia: false,
655655
},
656656
{
657-
name: "application/json with charset=UTF-8 should be accepted",
658-
contentType: "application/json; charset=UTF-8",
657+
name: "application/json with charset=UTF-8 should be accepted",
658+
contentType: "application/json; charset=UTF-8",
659659
expectUnsupportedMedia: false,
660660
},
661661
{
662-
name: "completely wrong content type is rejected",
663-
contentType: "text/plain",
662+
name: "completely wrong content type is rejected",
663+
contentType: "text/plain",
664664
expectUnsupportedMedia: true,
665665
},
666666
{
667-
name: "empty content type is rejected",
668-
contentType: "",
667+
name: "empty content type is rejected",
668+
contentType: "",
669669
expectUnsupportedMedia: true,
670670
},
671671
}

0 commit comments

Comments
 (0)