- Notifications
You must be signed in to change notification settings - Fork3k
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
base:main
Are you sure you want to change the base?
Conversation
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.
tommaso-moro left a comment
There was a problem hiding this 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!

Uh oh!
There was an error while loading.Please reload this page.
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 commentedOct 31, 2025
Hi@tommaso-moro, thank you so much for the detailed review and suggestions! I've updated the PR following your recommendations:
Regarding |


Uh oh!
There was an error while loading.Please reload this page.
Problem
The
get_discussiontool lacked important metadata fields already available inget_issue, making it difficultto determine discussion status.
Solution
Added discussion metadata fields:
Implementation Details
Modified
GetDiscussionto returnmap[string]interface{}instead ofgithub.Discussionstruct becausego-github v74's Discussion type lacks
isAnsweredandanswerChosenAtfields. This approach mirrors existingfunctions:
ListDiscussionsandGetDiscussionCommentsuse similar patterns.Changes Made
Statefield withClosed(Boolean)AnsweredAtfieldAnswerChosenAtfor answer timestampTesting
All tests pass with updated snapshots. Linter reports no issues. Backward compatibility verified.
Fixes#1303