Skip to content

fix: get_discussion graphQL invalid field #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions pkg/github/discussions.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func GetDiscussion(getGQLClient GetGQLClientFn, t translations.TranslationHelper
Discussion struct {
Number githubv4.Int
Body githubv4.String
State githubv4.String
CreatedAt githubv4.DateTime
URL githubv4.String `graphql:"url"`
Category struct {
Expand All @@ -213,16 +212,13 @@ func GetDiscussion(getGQLClient GetGQLClientFn, t translations.TranslationHelper
return mcp.NewToolResultError(err.Error()), nil
}
d := q.Repository.Discussion
discussion := &github.Issue{
discussion := &github.Discussion{
Number: github.Ptr(int(d.Number)),
Body: github.Ptr(string(d.Body)),
State: github.Ptr(string(d.State)),
HTMLURL: github.Ptr(string(d.URL)),
CreatedAt: &github.Timestamp{Time: d.CreatedAt.Time},
Labels: []*github.Label{
{
Name: github.Ptr(fmt.Sprintf("category:%s", string(d.Category.Name))),
},
DiscussionCategory: &github.DiscussionCategory{
Name: github.Ptr(string(d.Category.Name)),
},
}
out, err := json.Marshal(discussion)
Expand Down
19 changes: 6 additions & 13 deletions pkg/github/discussions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ func Test_GetDiscussion(t *testing.T) {
Discussion struct {
Number githubv4.Int
Body githubv4.String
State githubv4.String
CreatedAt githubv4.DateTime
URL githubv4.String `graphql:"url"`
Category struct {
Expand All @@ -218,7 +217,7 @@ func Test_GetDiscussion(t *testing.T) {
name string
response githubv4mock.GQLResponse
expectError bool
expected *github.Issue
expected *github.Discussion
errContains string
}{
{
Expand All @@ -227,23 +226,19 @@ func Test_GetDiscussion(t *testing.T) {
"repository": map[string]any{"discussion": map[string]any{
"number": 1,
"body": "This is a test discussion",
"state": "open",
"url": "https://github.com/owner/repo/discussions/1",
"createdAt": "2025-04-25T12:00:00Z",
"category": map[string]any{"name": "General"},
}},
}),
expectError: false,
expected: &github.Issue{
expected: &github.Discussion{
HTMLURL: github.Ptr("https://github.com/owner/repo/discussions/1"),
Number: github.Ptr(1),
Body: github.Ptr("This is a test discussion"),
State: github.Ptr("open"),
CreatedAt: &github.Timestamp{Time: time.Date(2025, 4, 25, 12, 0, 0, 0, time.UTC)},
Labels: []*github.Label{
{
Name: github.Ptr("category:General"),
},
DiscussionCategory: &github.DiscussionCategory{
Name: github.Ptr("General"),
},
},
},
Expand Down Expand Up @@ -272,15 +267,13 @@ func Test_GetDiscussion(t *testing.T) {
}

require.NoError(t, err)
var out github.Issue
var out github.Discussion
require.NoError(t, json.Unmarshal([]byte(text), &out))
assert.Equal(t, *tc.expected.HTMLURL, *out.HTMLURL)
assert.Equal(t, *tc.expected.Number, *out.Number)
assert.Equal(t, *tc.expected.Body, *out.Body)
assert.Equal(t, *tc.expected.State, *out.State)
// Check category label
require.Len(t, out.Labels, 1)
assert.Equal(t, *tc.expected.Labels[0].Name, *out.Labels[0].Name)
assert.Equal(t, *tc.expected.DiscussionCategory.Name, *out.DiscussionCategory.Name)
})
}
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy