fix: gh project item-edit error when editing Draft Issue with only one (title/body) flag#12787
Open
ManManavadaria wants to merge 1 commit intocli:trunkfrom
Open
Conversation
…with partial flags
|
Thanks for your pull request! Unfortunately, it doesn't meet the minimum requirements for review:
Please update your PR to address the above. Requirements:
This PR will be automatically closed in 7 days if these requirements are not met. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes incorrect behavior when editing a Draft Issue with only
--titleor only--body:gh project item-edit --project-id 1 --id ID_**** --title "new title"Previously this updated the title but set the body to an empty string.
Now the existing body is preserved and only the title is updated.
gh project item-edit --project-id 1 --id ID_**** --body "new body"Previously this caused a GraphQL error: "Title can't be empty".
Now the existing title is preserved and only the body is updated.
The GitHub API’s
updateProjectV2DraftIssuemutation requires bothtitleandbodyin the input. When the user passes only one flag, we now fetch the current draft issue, keep the other field unchanged, and send a partial update.Fixes #12726
Changes
titleChangedandbodyChanged(usingcmd.Flags().Changed(...)) so we distinguish “user passed--title” from “user passed--body” and from “user passed both”. This allows correct partial updates and avoids overwriting the other field with an empty string.--titleor--bodyis passed, we fetch the current draft issue via anode(id)query and use its title/body in mutation for the field that wasn’t available.Queryon the shared client so item-edit can run the draft-issue fetch query.