Skip to content

Conversation

@Higangssh
Copy link

Fixes #1303

Problem

The get_discussion tool was missing important state metadata fields that are already available in the
get_issue tool, making it difficult to determine discussion status.

Solution

Added four state metadata fields to the get_discussion tool:

  • state - Discussion state (OPEN, CLOSED, etc.)
  • isAnswered - Whether the discussion has an accepted answer
  • answeredAt - Timestamp when the answer was provided (optional)
  • answerChosenAt - Timestamp when the answer was selected (optional)

Implementation

Modified GetDiscussion to return these fields using a map[string]interface{} response instead of the
github.Discussion struct, since go-github v74's Discussion type doesn't include the isAnswered and
answeredAt fields.

This approach is consistent with existing functions in this codebase:

  • ListDiscussions uses map response (discussions.go:244)
  • GetDiscussionComments uses map response (discussions.go:448)

All discussion-related tools now follow the same pattern due to GraphQL API limitations in the go-github library.

Changes

  • Updated NodeFragment struct with new fields
  • Modified GetDiscussion GraphQL query to fetch state metadata
  • Added nil checks for optional timestamp fields
  • Updated all test cases and mock data

Testing

All tests pass with updated snapshots. Linter reports no issues. Verified backward compatibility with existing
discussion functions.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_discussion not returning whether discussion is open/closed

1 participant