Skip to content

gh pr create --web does not respect title and body arguments #10527

Description

@sislr

with gh pr create --fill --title "test" --body "ticket number" the title and body options take precedence and overwrite any autofilled content as stated in the docs:

It's important to notice that if the `--title` and/or `--body` are also provided
alongside `--fill`, the values specified by `--title` and/or `--body` will
take precedence and overwrite any autofilled content

however, this does not seem to be the case when using the --web flag as well: gh pr create --fill --title "test" --body "ticket number" --web. this does not prioritise the title and body options..

Affected version

2.67.0 (2025-02-11)

Steps to reproduce the behavior

  1. gh pr create --fill --title "test" --body "ticket number" --web
  2. See image

Image

Expected vs actual behavior

Expected: gh pr create --assignee @me --fill --title "test" --body "ticket number" --web should prioritise the title and body options with the web flag as well

Activity

  1. added
    bugSomething isn't working
    on Mar 3, 2025
  2. self-assigned this
    on Mar 3, 2025
  3. jtmcg commented on Mar 3, 2025

    @jtmcg
    Contributor

    Interesting find, @simon-isler. I've confirmed I'm seeing the same behavior. In particular, it looks like these get populated by the query params in the url when we open the page. Specifically, this bit looks suspect:

    (edit: don't know why this isn't embedding a preview)
    https://github.com/cli/cli/blob/5e21f6ac17e4eda480258d6c370987582a22ee9b/pkg/cmd/pr/create/create.go#L282C30-L285

    Acceptance Criteria

    Given I have a branch any number of commits
    when I use gh pr create --web --fill with --title "<title>" and/or --body "<body>"
    then the PR on the web browser is pre-filled with the title and body provided in the command and NOT the default behavior of the --fill flag

  4. added
    priority-3Affects a small number of users or is largely cosmetic
    gh-prrelating to the gh pr command
    and removed on Mar 3, 2025
  5. sislr commented on Mar 4, 2025

    @sislr
    Author

    thanks @jtmcg! looking forward to investigate this

  6. removed their assignment
    on Apr 23, 2025
  7. andyfeller commented on Jul 14, 2025

    @andyfeller
    Contributor

    Reopening this issue as #10547 was reverted due to regression in #11277 with preliminary notes captured in #11277 (comment)

  8. self-assigned this
    on Jul 15, 2025
  9. added
    coreThis issue is not accepting PRs from outside contributors
    and removed on Jul 25, 2025
  10. babakks commented on Aug 7, 2025

    @babakks
    Member

    TL;DR

    Due to complexity of the pr create command implementation and that the initial fix for this issue (PR #10547) caused a regression (#11277), we decided to follow a more resilient approach toward fixing this. That's why I've closed my new PR on this (#11306).

    Over an internal discussion with @andyfeller and @BagToad, we decided to fix this issue in two steps:

    1. First step: fixing the issue with a minimum set of changes, but with the addition of necessary acceptance tests.

    2. Second step: refactoring the logic in the NewIssueState function toward a better readable, less-side-effect implementation. In other words it's to pay the tech debt.

    Since the first step explained above actually fixes the issue, we don't need another issue for it. I'll write down the A/C in another comment.

    Effect of various gh pr create in --web mode

    We're now talking about the --web mode operation, not the interactive/non-interactive flows.

    To have a clear understanding of what is the expected behaviour we need to lay out an exhaustive list of possible combinations of options and explain the desired outcome for each. Since the --fill* options can affect both --title and --body, I'm going to investigate them separately.

    Note

    --fill* means any of --fill, --fill-first, or --fill-verbose options. These options are mutually exclusive.

    Determining PR title

    Here's the order of precedence of options that can be used to specify a PR's title. Lower numbers (higher in the list) take precedence over the higher numbers:

    1. --title: PR title input box must be pre-filled with "foo".
    2. --fill*: PR title input box must be pre-filled based on commit history.
    3. no options: the web GUI determines the pre-filled value for PR title.

    Determining PR body

    1. --body-file <FILE>: PR body input box must be prefilled with the content of the given <FILE>.
    2. --body foo: PR body input box must be prefilled with "foo".
    3. --fill*: PR body input box must be prefilled based on commit history.
    4. --template <FILE>: PR body input box must be prefilled with the content of the given <FILE>.
    5. no options: the web GUI determines the pre-filled value for PR body.

    Note

    The --template and --body (or --body-file) options are mutually exclusive.

    Note

    --editor and --recover options are not applicable in --web mode.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreThis issue is not accepting PRs from outside contributorsgh-prrelating to the gh pr commandpriority-3Affects a small number of users or is largely cosmetic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions