| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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.
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!
Sorry, something went wrong.
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 isAnswered:Following your suggestion to use the GraphQL API Explorer, I tested the available fields and found that isAnswered is actually a valid field in the Discussion type. Evidence:
query {
repository(owner: "github", name: "github-mcp-server") {
discussion(number: 1248) {
isAnswered
answerChosenAt
}
}
}
Both queries executed successfully without errors, confirming that isAnswered is valid. Given this, I've kept isAnswered 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 from answerChosenAt != nil instead, or is this approach acceptable? Thank you again for your help! 🙏
---
|
Sorry, something went wrong.
There was a problem hiding this comment.
Nice one! Thank you for your work on this 🚀
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Problem
The get_discussion tool lacked important metadata fields already available in get_issue, making it difficult
to determine discussion status.
Solution
Added discussion metadata fields:
Implementation Details
Modified GetDiscussion to return map[string]interface{} instead of github.Discussion struct because
go-github v74's Discussion type lacks isAnswered and answerChosenAt fields. This approach mirrors existing
functions: ListDiscussions and GetDiscussionComments use similar patterns.
Changes Made
Testing
All tests pass with updated snapshots. Linter reports no issues. Backward compatibility verified.
Fixes #1303