-
Notifications
You must be signed in to change notification settings - Fork 3k
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 our terms of service and privacy 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?
Add discussion metadata fields to get_discussion tool #1305
Conversation
Fixes github#1303 The get_discussion tool was missing important state metadata that's already available in get_issue. Added four fields to provide complete discussion 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 selected Changed GetDiscussion to return a map instead of github.Discussion struct since the go-github library doesn't include all these fields in its type definition. This approach is consistent with other functions in this codebase (ListDiscussions, GetDiscussionComments). All tests pass and linter checks pass.
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 and AnsweredAt don't exist on Discussion.
Instead of State you can use the closed field and then update the response map to use "closed": bool(d.Closed). As to the other two, I would recommend using answerChosenAt, and deriving isAnswered from it (specifically, it will be equivalent to answerChosenAt != nil).
I also recommend using the official GitHub 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!
pkg/github/discussions.go
Outdated
| Title githubv4.String | ||
| CreatedAt githubv4.DateTime | ||
| UpdatedAt githubv4.DateTime | ||
| State githubv4.String |
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.
I believe State, AnsweredAt and IsAnswered are not valid fields for the Discussion type
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 timestamp Updated both implementation and tests to match actual GitHub GraphQL schema. All tests passing.
|
Hi @tommaso-moro, thank you so much for the detailed review and suggestions! I've updated the PR following your recommendations:
Regarding
|


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