From 8f1eb1d0966096b388cc5fcc7981d27512207aab Mon Sep 17 00:00:00 2001 From: Ksenia Bobrova Date: Wed, 10 Dec 2025 13:54:51 +0000 Subject: [PATCH 1/3] Correct lower-case issue state --- pkg/github/issues.go | 2 +- pkg/github/issues_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/github/issues.go b/pkg/github/issues.go index 46111a4d6..baabd510a 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -1384,7 +1384,7 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun // If the state has a value, cast into an array of strings var states []githubv4.IssueState if state != "" { - states = append(states, githubv4.IssueState(state)) + states = append(states, githubv4.IssueState(strings.ToUpper(state))) } else { states = []githubv4.IssueState{githubv4.IssueStateOpen, githubv4.IssueStateClosed} } diff --git a/pkg/github/issues_test.go b/pkg/github/issues_test.go index 48901ccdc..c4454624b 100644 --- a/pkg/github/issues_test.go +++ b/pkg/github/issues_test.go @@ -1183,6 +1183,16 @@ func Test_ListIssues(t *testing.T) { expectError: false, expectedCount: 2, }, + { + name: "filter by open state - lc", + reqParams: map[string]interface{}{ + "owner": "owner", + "repo": "repo", + "state": "open", + }, + expectError: false, + expectedCount: 2, + }, { name: "filter by closed state", reqParams: map[string]interface{}{ @@ -1229,6 +1239,9 @@ func Test_ListIssues(t *testing.T) { case "filter by open state": matcher := githubv4mock.NewQueryMatcher(qBasicNoLabels, varsOpenOnly, mockResponseOpenOnly) httpClient = githubv4mock.NewMockedHTTPClient(matcher) + case "filter by open state - lc": + matcher := githubv4mock.NewQueryMatcher(qBasicNoLabels, varsOpenOnly, mockResponseOpenOnly) + httpClient = githubv4mock.NewMockedHTTPClient(matcher) case "filter by closed state": matcher := githubv4mock.NewQueryMatcher(qBasicNoLabels, varsClosedOnly, mockResponseClosedOnly) httpClient = githubv4mock.NewMockedHTTPClient(matcher) From c94200d3ee22b26a1ef800f8b050789a08d42176 Mon Sep 17 00:00:00 2001 From: Ksenia Bobrova Date: Wed, 10 Dec 2025 14:27:12 +0000 Subject: [PATCH 2/3] Uppercase orderBy and direction as well --- pkg/github/issues.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/github/issues.go b/pkg/github/issues.go index baabd510a..acf73b131 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -1467,8 +1467,8 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun "owner": githubv4.String(owner), "repo": githubv4.String(repo), "states": states, - "orderBy": githubv4.IssueOrderField(orderBy), - "direction": githubv4.OrderDirection(direction), + "orderBy": githubv4.IssueOrderField(strings.ToUpper(orderBy)), + "direction": githubv4.OrderDirection(strings.ToUpper(direction)), "first": githubv4.Int(*paginationParams.First), } From 22b5ec978fc8a403ccf1b801b1ece6ea9ca332b3 Mon Sep 17 00:00:00 2001 From: Ksenia Bobrova Date: Wed, 10 Dec 2025 14:45:21 +0000 Subject: [PATCH 3/3] Auto-correct invalid enum parameters --- pkg/github/issues.go | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/pkg/github/issues.go b/pkg/github/issues.go index acf73b131..ec83e4efa 100644 --- a/pkg/github/issues.go +++ b/pkg/github/issues.go @@ -1381,11 +1381,14 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun return utils.NewToolResultError(err.Error()), nil, nil } - // If the state has a value, cast into an array of strings + // Normalize and filter by state + state = strings.ToUpper(state) var states []githubv4.IssueState - if state != "" { - states = append(states, githubv4.IssueState(strings.ToUpper(state))) - } else { + + switch state { + case "OPEN", "CLOSED": + states = []githubv4.IssueState{githubv4.IssueState(state)} + default: states = []githubv4.IssueState{githubv4.IssueStateOpen, githubv4.IssueStateClosed} } @@ -1405,13 +1408,21 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun return utils.NewToolResultError(err.Error()), nil, nil } - // These variables are required for the GraphQL query to be set by default - // If orderBy is empty, default to CREATED_AT - if orderBy == "" { + // Normalize and validate orderBy + orderBy = strings.ToUpper(orderBy) + switch orderBy { + case "CREATED_AT", "UPDATED_AT", "COMMENTS": + // Valid, keep as is + default: orderBy = "CREATED_AT" } - // If direction is empty, default to DESC - if direction == "" { + + // Normalize and validate direction + direction = strings.ToUpper(direction) + switch direction { + case "ASC", "DESC": + // Valid, keep as is + default: direction = "DESC" } @@ -1467,8 +1478,8 @@ func ListIssues(getGQLClient GetGQLClientFn, t translations.TranslationHelperFun "owner": githubv4.String(owner), "repo": githubv4.String(repo), "states": states, - "orderBy": githubv4.IssueOrderField(strings.ToUpper(orderBy)), - "direction": githubv4.OrderDirection(strings.ToUpper(direction)), + "orderBy": githubv4.IssueOrderField(orderBy), + "direction": githubv4.OrderDirection(direction), "first": githubv4.Int(*paginationParams.First), }