Repository navigation
Closed
Labels
bugSomething isn't working
Description
Describe the bug
When trying to create a Pull Request through gh pr create, I run into the following error:
pull request create failed: GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and conftest-app-metrics, Head ref must be a branch
gh version 1.0.0 (2020-09-16)
https://github.com/cli/cli/releases/tag/v1.0.0
Steps to reproduce the behavior
- Fork a repo
- Clone and set origin and upstream
- Create a branch and commit some changes
- Run the following:
gh pr create --fill
Expected vs actual behavior
I would have expected to see the PR created. Instead it results in the following error message.
pull request create failed: GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and conftest-app-metrics, Head ref must be a branch
Logs
$ DEBUG=api gh pr create --fill
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
* Request at 2020-09-18 16:23:58.899000113 -0600 MDT m=+0.032056143
* Request to https://api.github.com/graphql
> POST /graphql HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github.antiope-preview+json
> Authorization: token
> Content-Type: application/json; charset=utf-8
> User-Agent: GitHub CLI 1.0.0
{
"query": "\n\tquery RepositoryInfo($owner: String!, $name: String!) {\n\t\trepository(owner: $owner, name: $name) {\n\t\t\tid\n\t\t\tname\n\t\t\towner { login }\n\t\t\thasIssuesEnabled\n\t\t\tdescription\n\t\t\tviewerPermission\n\t\t\tdefaultBranchRef {\n\t\t\t\tname\n\t\t\t}\n\t\t}\n\t}",
"variables": {
"name": "bitly",
"owner": "bitly"
}
}
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
< Cache-Control: no-cache
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Fri, 18 Sep 2020 22:24:36 GMT
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Server: GitHub.com
< Status: 200 OK
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-Accepted-Oauth-Scopes: repo
< X-Content-Type-Options: nosniff
< X-Frame-Options: deny
< X-Github-Media-Type: github.antiope-preview; format=json
< X-Github-Request-Id:
< X-Oauth-Client-Id:
< X-Oauth-Scopes: gist, read:org, repo
< X-Ratelimit-Limit: 5000
< X-Ratelimit-Remaining: 4951
< X-Ratelimit-Reset: 1600469053
< X-Ratelimit-Used: 49
< X-Xss-Protection: 1; mode=block
{
"data": {
"repository": {
"id": "MDEwOlJlcG9zaXRvcnkxNzYxMDE4",
"name": "bitly",
"owner": {
"login": "bitly"
},
"hasIssuesEnabled": true,
"description": "Bitly core repository",
"viewerPermission": "WRITE",
"defaultBranchRef": {
"name": "master"
}
}
}
}
* Request took 512.90788ms
[git symbolic-ref --quiet --short HEAD]
[git status --porcelain]
[git config --get-regexp ^branch\.conftest-app-metrics\.(remote|merge)$]
[git show-ref --verify -- HEAD refs/remotes/jharshman/conftest-app-metrics refs/remotes/origin/conftest-app-metrics refs/remotes/bitly/conftest-app-metrics refs/remotes/jharshman/conftest-app-metrics refs/remotes/mrwoof/conftest-app-metrics]
[git -c log.ShowSignature=false log --pretty=format:%H,%s --cherry origin/master...conftest-app-metrics]
* Request at 2020-09-18 16:23:59.506737366 -0600 MDT m=+0.639793409
* Request to https://api.github.com/graphql
> POST /graphql HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github.antiope-preview+json
> Authorization: token
> Content-Type: application/json; charset=utf-8
> User-Agent: GitHub CLI 1.0.0
{
"query": "\n\tquery PullRequestForBranch($owner: String!, $repo: String!, $headRefName: String!) {\n\t\trepository(owner: $owner, name: $repo) {\n\t\t\tpullRequests(headRefName: $headRefName, states: OPEN, first: 30) {\n\t\t\t\tnodes {\n\t\t\t\t\tid\n\t\t\t\t\tnumber\n\t\t\t\t\ttitle\n\t\t\t\t\tstate\n\t\t\t\t\tbody\n\t\t\t\t\tmergeable\n\t\t\t\t\tauthor {\n\t\t\t\t\t\tlogin\n\t\t\t\t\t}\n\t\t\t\t\tcommits(last: 1) {\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t nodes {\n\t\t\t\t\t\t commit {\n\t\t\t\t\t\t\t oid\n\t\t\t\t\t\t\t\tstatusCheckRollup {\n\t\t\t\t\t\t\t\t contexts(last: 100) {\n\t\t\t\t\t\t\t\t nodes {\n\t\t\t\t\t\t\t\t\t\t ...on StatusContext {\n\t\t\t\t\t\t\t\t\t\t\t context\n\t\t\t\t\t\t\t\t\t\t\t\tstate\n\t\t\t\t\t\t\t\t\t\t\t targetUrl\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t...on CheckRun {\n\t\t\t\t\t\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\t\t\t\t\t\tstatus\n\t\t\t\t\t\t\t\t\t\t\t\tconclusion\n\t\t\t\t\t\t\t\t\t\t\t\tstartedAt\n\t\t\t\t\t\t\t\t\t\t\t\tcompletedAt\n\t\t\t\t\t\t\t\t\t\t\t\tdetailsUrl\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t }\n\t\t\t\t\t}\n\t\t\t\t\turl\n\t\t\t\t\tbaseRefName\n\t\t\t\t\theadRefName\n\t\t\t\t\theadRepositoryOwner {\n\t\t\t\t\t\tlogin\n\t\t\t\t\t}\n\t\t\t\t\theadRepository {\n\t\t\t\t\t\tname\n\t\t\t\t\t}\n\t\t\t\t\tisCrossRepository\n\t\t\t\t\tisDraft\n\t\t\t\t\tmaintainerCanModify\n\t\t\t\t\treviewRequests(first: 100) {\n\t\t\t\t\t\tnodes {\n\t\t\t\t\t\t\trequestedReviewer {\n\t\t\t\t\t\t\t\t__typename\n\t\t\t\t\t\t\t\t...on User {\n\t\t\t\t\t\t\t\t\tlogin\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t...on Team {\n\t\t\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t}\n\t\t\t\t\treviews(last: 100) {\n\t\t\t\t\t\tnodes {\n\t\t\t\t\t\t\tauthor {\n\t\t\t\t\t\t\t login\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstate\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t}\n\t\t\t\t\tassignees(first: 100) {\n\t\t\t\t\t\tnodes {\n\t\t\t\t\t\t\tlogin\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t}\n\t\t\t\t\tlabels(first: 100) {\n\t\t\t\t\t\tnodes {\n\t\t\t\t\t\t\tname\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t}\n\t\t\t\t\tprojectCards(first: 100) {\n\t\t\t\t\t\tnodes {\n\t\t\t\t\t\t\tproject {\n\t\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcolumn {\n\t\t\t\t\t\t\t\tname\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\ttotalCount\n\t\t\t\t\t}\n\t\t\t\t\tmilestone{\n\t\t\t\t\t\ttitle\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}",
"variables": {
"headRefName": "conftest-app-metrics",
"owner": "bitly",
"repo": "bitly"
}
}
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
< Cache-Control: no-cache
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Fri, 18 Sep 2020 22:24:36 GMT
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Server: GitHub.com
< Status: 200 OK
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-Accepted-Oauth-Scopes: repo
< X-Content-Type-Options: nosniff
< X-Frame-Options: deny
< X-Github-Media-Type: github.antiope-preview; format=json
< X-Github-Request-Id:
< X-Oauth-Client-Id:
< X-Oauth-Scopes: gist, read:org, repo
< X-Ratelimit-Limit: 5000
< X-Ratelimit-Remaining: 4950
< X-Ratelimit-Reset: 1600469053
< X-Ratelimit-Used: 50
< X-Xss-Protection: 1; mode=block
{
"data": {
"repository": {
"pullRequests": {
"nodes": []
}
}
}
}
* Request took 192.253972ms
* Request at 2020-09-18 16:23:59.699880362 -0600 MDT m=+0.832936377
* Request to https://api.github.com/graphql
> POST /graphql HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github.antiope-preview+json
> Authorization: token
> Content-Type: application/json; charset=utf-8
> User-Agent: GitHub CLI 1.0.0
{
"query": "\n\t\tmutation PullRequestCreate($input: CreatePullRequestInput!) {\n\t\t\tcreatePullRequest(input: $input) {\n\t\t\t\tpullRequest {\n\t\t\t\t\tid\n\t\t\t\t\turl\n\t\t\t\t}\n\t\t\t}\n\t}",
"variables": {
"input": {
"baseRefName": "master",
"body": "",
"draft": false,
"headRefName": "conftest-app-metrics",
"repositoryId": "MDEwOlJlcG9zaXRvcnkxNzYxMDE4",
"title": "conftest app metrics"
}
}
}
< HTTP/1.1 200 OK
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
< Cache-Control: no-cache
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Fri, 18 Sep 2020 22:24:36 GMT
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Server: GitHub.com
< Status: 200 OK
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-Accepted-Oauth-Scopes: repo
< X-Content-Type-Options: nosniff
< X-Frame-Options: deny
< X-Github-Media-Type: github.antiope-preview; format=json
< X-Github-Request-Id:
< X-Oauth-Client-Id:
< X-Oauth-Scopes: gist, read:org, repo
< X-Ratelimit-Limit: 5000
< X-Ratelimit-Remaining: 4949
< X-Ratelimit-Reset: 1600469053
< X-Ratelimit-Used: 51
< X-Xss-Protection: 1; mode=block
{
"data": {
"createPullRequest": {
"pullRequest": null
}
},
"errors": [
{
"type": "UNPROCESSABLE",
"path": [
"createPullRequest"
],
"locations": [
{
"line": 3,
"column": 4
}
],
"message": "Head sha can't be blank, Base sha can't be blank, No commits between master and conftest-app-metrics, Head ref must be a branch"
}
]
}
* Request took 458.545525ms
pull request create failed: GraphQL error: Head sha can't be blank, Base sha can't be blank, No commits between master and conftest-app-metrics, Head ref must be a branch
Reacted by Aaron Gershman, Will Fuqua, Asanka Abeyweera, Angel, Tony, Geoffrey Martin-Noble, Sai Sandeep Rayanuthala, Luz de la Garza and Alex Maiorenko
Activity
Mr-istov commentedon Sep 21, 2020
In the new version
1.0.0they have changed the implementation forgh pr create: #1706Quote from the PR:
We no longer try to guess which is a suitable push target for the "head" branch. Instead, unless the user has already fully pushed their branch, we always present the user with a prompt:We never fork nor push without explicit user agreement anymore.mislav commentedon Sep 21, 2020
Hi @jharshman, thank you for reporting! Did you happen to already push the
conftest-app-metricsbranch to a remote before runningpr create, and if so, to which remote did you push it to? Did the branch have extra commits on top of the basemasterbranch?a5anka commentedon Sep 21, 2020
@mislav I also observed the same issue when I pushed to
originbefore creating the PR.Steps,
Hope you can also reproduce the issue following the above steps.
jharshman commentedon Sep 21, 2020
@mislav I verified this issue in two ways. The first being allowing the cli to prompt me for which remote to push to, and the second being the way @a5anka described above. In both cases the fork was used and resulted in the same error message.
mvdan commentedon Sep 22, 2020
I can confirm this issue. I too had fully pushed my branch to my fork via
git push -f -u mvdan, yetgh pr create --fillwould still fail like in the original post. I had to give it all the explicit flags to make it work:gh pr create --fill --base=master --head=mvdan:less-debugdir.bhrutledge commentedon Sep 22, 2020
Possibly related (or not, in which case I'm happy to file a separate issue).
I'm seeing similar behavior from
gh pr create --web, for a branch that was previously pushed toorigin.For example:
I would have expected:
I can achieve that with:
This changed with the upgrade to 1.0, i.e., I was seeing the expected behavior in the last version.
mislav commentedon Sep 22, 2020
Thank you for all the info! I'm thinking that this might be related or identical to #1762
[-]PR Create - GraphQL error: Head sha can't be blank[/-][+]PR Create - GraphQL error due to wrong head branch detected[/+]jharshman commentedon Sep 22, 2020
@mislav interestingly enough, it functioned as expected when the CLI was used to create the fork as well.
geerlingguy commentedon Sep 24, 2020
I have been running into this issue on all my repos for the past couple days since upgrading to the latest version of
gh. It's quite annoying as I really only useghto create PRs, and that functionality seems broken (was working fine for months).Is there any workaround? For now I'm having to go to the browser to create PRs like it's 1999.
bhrutledge commentedon Sep 24, 2020
@geerlingguy I'm working around this by using the
--headoption, as noted in #1820 (comment) (and in the preceding comment). I think you could define an alias (probably with the--shelloption) to shorten that up.mislav commentedon Sep 29, 2020
Thank you everyone for your reports and patience! Currently fixed in trunk; we will cut a release soon 👍
lszomoru commentedon Oct 2, 2020
@mislav, do you have an ETA on the release?
Also do you know when the GH Actions agents will be updated as we are using the GH CLI from an action. Thanks!
Workaround bug in gh cli (#3338)
johnpapa commentedon Oct 15, 2020
it appears GH 1.1.0 fixes this
cveneziani commentedon Oct 22, 2020
Currently using
gh version 1.1.0 (2020-10-06)and I still experience this error.mislav commentedon Oct 23, 2020
@cveneziani Please open another issue! Also include your git remote and branch setup in your report 🙇
armsp commentedon Nov 14, 2020
@mislav I have the same issue when I try this from a github action worker.
I commands I have used inside the worker are -
Is this the correct way to make a PR from a local git branch to the remote master/main branch?
Pass --head argument to gh due to buggy
Pass --head argument to gh due to bug in cli
Pass --head, --repo arguments to gh due to bug in cli