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 specifying state change reason toupdate_issue tool#1073

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

Merged
tonytrg merged 9 commits intomainfromkerobbi/add-state-change-reason
Sep 12, 2025

Conversation

kerobbi
Copy link
Contributor

@kerobbikerobbi commentedSep 10, 2025
edited
Loading

This PR adds support for astate_reason parameter to theupdate_issue tool, enabling users to specify the reason when changing an issue's state (particularly when closing issues).

Valid values are:completed,not_planned,duplicate

When closing an issue as duplicate, the current implementation mandates the presence ofduplicate_of (new parameter), specifying which issue the target issue is a duplicate of, replicating the user experience for duplicate management in the UI.

Status

  • TheREST API allows closing an issue as duplicate, but does not give the ability to specify the issue the target issue is a duplicate of.
  • The GraphQL APIoffers the above functionality; however, the underlyingshurcooL/githubv4 library does not fully align with what the API offers.

Chosen approach

  • REST API for base functionality, GraphQL API to close as duplicate.
  • Limitation: The underlyinggithubv4 library does not fully align with what the GraphQL API offers, custom structs need to be created to get this working.

Alternatives considered

REST API + automatic closing comment
  • Automatically post a comment (i.e., "Duplicate of X") before closing the issue.

  • Discarded because this introduces complexity for a feature that could be manually replicated using theadd_issue_comment tool.

Contribute toshurcooL/githubv4
  • It is possible to open a PR inshurcooL/githubv4 and make the necessary changes for this work (i.e., updateCloseIssue andCloseIssueInput structs).
  • Although a better approach, I've discarded this mainly due to the repo activity - it honestly seems like contributions have not been considered by the maintainer in a while

Future improvements

  • If and when up-to-date support for closing issues as duplicates is added inshurcooL/githubv4, we could remove the custom structs created for this PR.

Closes:#949

@kerobbikerobbi requested a review froma team as acode ownerSeptember 10, 2025 09:36
@CopilotCopilotAI review requested due to automatic review settingsSeptember 10, 2025 09:36
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for specifying reasons when changing issue states in theupdate_issue tool, with special handling for duplicate issues using the GraphQL API.

  • Addsstate_reason parameter supporting values:completed,not_planned,duplicate,reopened
  • Addsduplicate_of parameter for specifying the target issue when marking as duplicate
  • Implements dual API approach: REST for basic state changes, GraphQL for duplicate handling

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
pkg/github/tools.goUpdates UpdateIssue function signature to include GraphQL client
pkg/github/issues.goAdds state reason functionality with custom GraphQL structs and dual API logic
pkg/github/issues_test.goAdds comprehensive test coverage for new state reason functionality
pkg/github/toolsnaps/update_issue.snapUpdates tool schema to include new state_reason and duplicate_of parameters
README.mdDocuments the new parameters in the tool reference

Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.

Copy link
Contributor

@tonytrgtonytrg left a comment
edited
Loading

Choose a reason for hiding this comment

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

Sorry couldn't do a full review today.

Thanks for tackling this complicate case 💯 , it is probably owed due to limitations of apis, but we are introducing a hefty amount of conditional branches. Can this maybe be simplified?

From what I am understanding from the pr description only state_reasonduplicate require the graphql api. Can the graphql client relevant code be more isolated from the rest client code - for example any state change is solely handled by the graphql, if that is possible.

Copy link
Contributor

@LuluBeatsonLuluBeatson left a comment

Choose a reason for hiding this comment

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

Great work! I've tried out the tool with all state changes

Only thing I'd suggest is reducing the complexity of the tool handler. Added some light suggestions of places, but feel free to think of your own ways.

ifresp.StatusCode!=http.StatusOK {
body,err:=io.ReadAll(resp.Body)
// Handle GraphQL API updates (state_reason = "duplicate")
ifgqlUpdateNeeded {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could consider extracting into 2 separate functions for the REST and GraphQL updaters, which could make unit testing a bit easier.

It also seems like the GraphQL capabilities are a superset of the REST API, so could we use only GraphQL?

Copy link
ContributorAuthor

@kerobbikerobbiSep 11, 2025
edited
Loading

Choose a reason for hiding this comment

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

Looked better into this and we could indeed use only GQL (i.e.,updateIssue /updateIssueInput). However, I believe the current hybrid approach is actually more optimal, mainly due to the amount of ID resolution overhead that would be needed if we go full GQL. I did refactor everything for better readability/separation of concerns, but more than happy to review this further if needed.

LuluBeatson reacted with heart emoji
Copy link
Contributor

@tonytrgtonytrg left a comment

Choose a reason for hiding this comment

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

Thank you, this looks great!

kerobbi reacted with heart emoji
@tonytrgtonytrg merged commitb6486a3 intomainSep 12, 2025
16 checks passed
@tonytrgtonytrg deleted the kerobbi/add-state-change-reason branchSeptember 12, 2025 14:04
nickytonline pushed a commit to nickytonline/github-mcp-http that referenced this pull requestOct 4, 2025
* add state_reason param* add close as duplicate functionality* refactor and improve tests* fix state reason validation logic and update tests* move state and state reason handling to gql* fix marshal failures* address latest feedback
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@LuluBeatsonLuluBeatsonLuluBeatson requested changes

@tonytrgtonytrgtonytrg approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add ability to specify reason why issue is being closed, when closing issue
3 participants
@kerobbi@tonytrg@LuluBeatson

[8]ページ先頭

©2009-2025 Movatter.jp