Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add discussion metadata fields to get_discussion tool#1305

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Higangssh wants to merge2 commits intogithub:main
base:main
Choose a base branch
Loading
fromHigangssh:feature/add-discussion-state-fields

Conversation

@Higangssh
Copy link

@HigangsshHigangssh commentedOct 25, 2025
edited
Loading

Problem

Theget_discussion tool lacked important metadata fields already available inget_issue, making it difficult
to determine discussion status.

Solution

Added discussion metadata fields:

  • closed - Boolean indicating if the discussion is closed
  • isAnswered - Whether discussion has an accepted answer
  • answerChosenAt - Timestamp when answer was selected (optional)

Implementation Details

ModifiedGetDiscussion to returnmap[string]interface{} instead ofgithub.Discussion struct because
go-github v74's Discussion type lacksisAnswered andanswerChosenAt fields. This approach mirrors existing
functions:ListDiscussions andGetDiscussionComments use similar patterns.

Changes Made

  • Updated Discussion field mappings to match GitHub GraphQL API schema
  • Replaced non-existentState field withClosed (Boolean)
  • Removed non-existentAnsweredAt field
  • UsingAnswerChosenAt for answer timestamp
  • Added nil checks for optional timestamp fields
  • Updated all test cases and mock data
  • All tests passing ✅

Testing

All tests pass with updated snapshots. Linter reports no issues. Backward compatibility verified.

Fixes#1303

Fixesgithub#1303The get_discussion tool was missing important state metadata that'salready available in get_issue. Added four fields to provide completediscussion status information:- state: Current discussion state (OPEN/CLOSED)- isAnswered: Whether the discussion has an accepted answer- answeredAt: Timestamp when answer was provided- answerChosenAt: Timestamp when answer was selectedChanged GetDiscussion to return a map instead of github.Discussionstruct since the go-github library doesn't include all these fieldsin its type definition. This approach is consistent with otherfunctions in this codebase (ListDiscussions, GetDiscussionComments).All tests pass and linter checks pass.
Copy link
Contributor

@tommaso-morotommaso-moro left a comment

Choose a reason for hiding this comment

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

Hi@Higangssh thank you for your work on this. I have tested it locally and it is not working (screenshot below), it looks like some of the fields are invalid. For example,State,IsAnswered andAnsweredAt don't exist onDiscussion.

Instead ofState you can use theclosed field and then update theresponse map to use"closed": bool(d.Closed). As to the other two, I would recommend usinganswerChosenAt, and derivingisAnswered from it (specifically, it will be equivalent toanswerChosenAt != nil).

I also recommend using the officialGitHub GraphQL API Explorer to play around with the query and see which fields are available and what they return.

If you can, it would be great if you could update this PR. Otherwise, I am also happy to do it if you prefer. Thank you!

Image

Changes:- Replace 'State' (doesn't exist) with 'Closed' (Boolean)- Remove 'AnsweredAt' (doesn't exist)- Keep 'IsAnswered' (verified to exist in GitHub GraphQL API)- Use 'AnswerChosenAt' for answer timestampUpdated both implementation and tests to match actual GitHub GraphQL schema.All tests passing.
@Higangssh
Copy link
Author

Hi@tommaso-moro, thank you so much for the detailed review and suggestions!

I've updated the PR following your recommendations:

  • StateClosed (Boolean)
  • AnsweredAt → Removed (usinganswerChosenAt instead)

RegardingisAnswered:

Following your suggestion to use the GraphQL API Explorer, I tested the available fields and found thatisAnswered is actually a valid field in the Discussion type.

Evidence:

  1. Official Documentation: TheGitHub GraphQL Reference listsisAnswered (Boolean) as a field for Discussion objects.

  2. GraphQL Query Test: I tested with both answered and unanswered discussions:

query {repository(owner:"github",name:"github-mcp-server") {discussion(number:1248) {isAnsweredanswerChosenAt       }     }   }
  • Answered discussion (1248):{ "isAnswered": true, "answerChosenAt": "2025-10-20T09:57:37Z" }
  • Unanswered discussion (1088):{ "isAnswered": false, "answerChosenAt": null }

Both queries executed successfully without errors, confirming thatisAnswered is valid.

Given this, I've keptisAnswered as a direct field query rather than deriving it. This approach uses the field that GitHub's API provides and is more efficient than client-side calculation.

Would you prefer I derive it fromanswerChosenAt != nil instead, or is this approach acceptable?

Thank you again for your help! 🙏


image---image

@HigangsshHigangssh changed the titleAdd state metadata fields to get_discussion toolAdd discussion metadata fields to get_discussion toolOct 31, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@tommaso-morotommaso-moroAwaiting requested review from tommaso-moro

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

get_discussion not returning whether discussion is open/closed

2 participants

@Higangssh@tommaso-moro

[8]ページ先頭

©2009-2025 Movatter.jp