Skip to content

Recreating a PR fails to include the body #3282

@waldyrious

Description

@waldyrious

Describe the bug

Recreating a failed PR successfully reuses the title, but not the body of the PR (gh version: 1.7.0).

Steps to reproduce the behavior

  1. Clone a repository
  2. Check out a new branch
  3. Make changes and stage them, but don't create a commit yet
  4. gh pr create and follow the prompts, including adding a body using the editor
  5. Once the PR creation fails, actually make the commit, and do gh pr create --recover as instructed by the error message
  6. When prompted for the title, press Enter to reuse the same title as before
  7. When prompted for the body, press Enter as well
  8. Finish the command and submit the PR

Expected vs actual behavior

I expected the same body message that I had used before to be included. Instead, the PR was created with an empty body.

I actually went and opened the json file mentioned in the error message, and to my relief the text I had typed before was there, so I was able to recover the content and paste it into the PR.

I'm not sure this can be classified as a bug — technically, the "skip editor" behavior for the body prompt is the same as when creating a new PR (i.e. the body becomes empty). But being a recovery procedure, it feels wrong not to acknowledge that there's a body text available and simply discard it silently unless one decides to enter the editor. Even then, there's no indication that the editor would be pre-filled with the saved content, so I'd be wary of overwriting the previous content (which is part of the reason why I pressed Enter to skip opening the editor).

Maybe showing an excerpt of the previously written body as a greyed out default for the body text (the same way it is done for the title) could help make this flow predictable.

Logs

For reference, the failure message of the original PR creation was this:

X operation failed. To restore: gh pr create --recover /var/folders/6p/m7980bc100g5q58dc14q7l6h0000gn/T/gh914700270.json`

pull request create failed: GraphQL error: No commits between <upstream>:master and <fork>:<pr-branch>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions