- Notifications
You must be signed in to change notification settings - Fork2.7k
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
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.
- Adds
state_reason
parameter supporting values:completed
,not_planned
,duplicate
,reopened
- Adds
duplicate_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
File | Description |
---|---|
pkg/github/tools.go | Updates UpdateIssue function signature to include GraphQL client |
pkg/github/issues.go | Adds state reason functionality with custom GraphQL structs and dual API logic |
pkg/github/issues_test.go | Adds comprehensive test coverage for new state reason functionality |
pkg/github/toolsnaps/update_issue.snap | Updates tool schema to include new state_reason and duplicate_of parameters |
README.md | Documents the new parameters in the tool reference |
Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
tonytrg left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
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.
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.
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.
Uh oh!
There was an error while loading.Please reload this page.
pkg/github/issues.go Outdated
ifresp.StatusCode!=http.StatusOK { | ||
body,err:=io.ReadAll(resp.Body) | ||
// Handle GraphQL API updates (state_reason = "duplicate") | ||
ifgqlUpdateNeeded { |
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.
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?
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.
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.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Thank you, this looks great!
b6486a3
intomainUh oh!
There was an error while loading.Please reload this page.
* 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
Uh oh!
There was an error while loading.Please reload this page.
This PR adds support for a
state_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 of
duplicate_of
(new parameter), specifying which issue the target issue is a duplicate of, replicating the user experience for duplicate management in the UI.Status
shurcooL/githubv4
library does not fully align with what the API offers.Chosen approach
githubv4
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 the
add_issue_comment
tool.Contribute to
shurcooL/githubv4
shurcooL/githubv4
and make the necessary changes for this work (i.e., updateCloseIssue
andCloseIssueInput
structs).Future improvements
shurcooL/githubv4
, we could remove the custom structs created for this PR.Closes:#949