Skip to content

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
ManManavadaria:fix-12726/item-edit-draft-issue-partial-update
Open

fix: gh project item-edit error when editing Draft Issue with only one (title/body) flag#12787
ManManavadaria wants to merge 1 commit intocli:trunkfrom
ManManavadaria:fix-12726/item-edit-draft-issue-partial-update

Conversation

@ManManavadaria
Copy link

Description

This PR fixes incorrect behavior when editing a Draft Issue with only --title or only --body:

  1. 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.

  2. 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 updateProjectV2DraftIssue mutation requires both title and body in 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

  • Flag tracking: Introduced titleChanged and bodyChanged (using cmd.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.
  • Draft issue fetch: When only one of --title or --body is passed, we fetch the current draft issue via a node(id) query and use its title/body in mutation for the field that wasn’t available.
  • queries package: Exposed Query on the shared client so item-edit can run the draft-issue fetch query.
  • Tests: Added tests according to the changes

@ManManavadaria ManManavadaria requested a review from a team as a code owner February 26, 2026 11:22
@github-actions github-actions bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed unmet-requirements and removed needs-triage needs to be reviewed labels Feb 26, 2026
@github-actions
Copy link

Thanks for your pull request! Unfortunately, it doesn't meet the minimum requirements for review:

  • None of the referenced issues have the help-wanted label

Please update your PR to address the above. Requirements:

  1. Include a detailed description of what this PR does
  2. Link to an issue with the help-wanted label (use Fixes #123 or Closes #123 if it resolves the issue)

This PR will be automatically closed in 7 days if these requirements are not met.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team unmet-requirements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gh project item-edit Can't Edit Only Draft Issue Title or Body

1 participant