Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating pull request: Unprocessable Entity (HTTP 422) #189

Closed
mrcasals opened this issue May 31, 2012 · 60 comments · Fixed by #2190
Closed

Error creating pull request: Unprocessable Entity (HTTP 422) #189

mrcasals opened this issue May 31, 2012 · 60 comments · Fixed by #2190

Comments

@mrcasals
Copy link

I can't open a pull request with hub. This is what I do:

$ git checkout -b new_branch
( some changes here)
$ git commit -m "Test commit"
$ git push origin new_branch
$ hub pull-request

And this is what I get from the last command:

(username and password lines)
Error creating pull request: Unprocessable Entity (HTTP 422)
field 'head_sha' is missing
field 'base_sha' is missing
base No commits between user:master and user:new_branch
@mislav
Copy link
Owner

mislav commented Jun 4, 2012

Well, the error message says: "No commits between user:master and user:new_branch".

That means you probably need to indicate the base for the pull request explicitly. What are your remotes setup, and do you want to send the pull request for "origin/master" or some other remote?

@sirkitree
Copy link

I just tried too and without specifying i got this error as well.

Here's what I used to merge a topic branch into master and convert the issue (3) into a pull request (which I must say is really handy!):

git pull-request -i 3 -b Lullabot:master -h Lullabot:3-press-release

Lullabot (in this example) is the name of the GitHub organization, so if this were one of my own personal repos, I would replace 'Lullabot' with 'sirkitree' (I think).

@mrcasals
Copy link
Author

mrcasals commented Jun 4, 2012

@sirkitree thanks for confirming this point. I did not update the issue because right after opening it I found my hub version was updated, and I thought it might have been solved... I'll take a look at the issue again this week, @mislav (I'm sorry, I'm really busy right now, exams at university)

@mislav
Copy link
Owner

mislav commented Jun 4, 2012

OK. I'll close this right now since it's most probably a problem with your workflow, not a bug in hub. The error is a validation error from GitHub.

Tips for working with pull-request:

  1. "origin" remote should point to the canonical repo. If you're working on a fork of opensource project, "origin" remote should point to the original project and some other remote can point to your fork. (I usually call that remote under my name, "mislav".)

  2. When you push a branch to your fork/project, have git set up upstream configuration. This is done with the -u flag for git-push:

    git push -u myfork feature_branch
    
  3. When pull-request's automatic resolution fails to guess what you want, use -h (head) and -b (base) options to be explicit.

@balexand
Copy link

balexand commented Jun 5, 2012

I'm getting this too. I've verified that there are commits between the branches in question. I've been using hub pull-request for a long time now without any issues and I've tripple checked my branches, so I think my workflow is all good. I'm guessing there's a new bug in Github?

@mislav
Copy link
Owner

mislav commented Jun 5, 2012

It would be great if one of you actually provided me all the details needed to debug this, i.e. remotes config, branches in question, upstream config for those branches. Bonus points if it's an opensource project

@balexand
Copy link

balexand commented Jun 5, 2012

I added a dummy commit (arbitrary whitespace change) to my head branch then it worked. Definitely a bug in Github.

A few days ago I was having a similar issue. A commit was not showing up on the commits index on github.com (https://github.com/balexand/private_project_name/commits/master). I was able to verify that the commit had in fact been pushed to origin by cloning my repo in a different folder. I waited an hour and it still didn't show up. Then I pushed a new dummy commit to master (arbitrary whitespace). After doing that, both the real commit and the dummy commit showed up on github.com instantly. I was not able to reproduce this issue or anything similar until now.

@balexand
Copy link

balexand commented Jun 5, 2012

@mislav I posted my last comment before I saw your response. If I see this issue again then I'll give you details before I push a new commit. Thanks! Are you a githubber (and thus have access to debug this on the server-side)?

@mislav
Copy link
Owner

mislav commented Jun 5, 2012

I worked at GH last year but not anymore. And even if I had access to server side, I would still need details

@sirkitree
Copy link

The problem I had was that when I pushed my branch remotely I did not set it to track with -u.

So, if you do this:
git push origin feature-branch
followed by
git pull-request -i [ticket-number]
it will not work.

But if you do this:
git push -u origin feature-branch
followed by
git pull-request -i [ticket-number]
it will work.

@mislav
Copy link
Owner

mislav commented Jun 13, 2012

Yes, setting up upstream configuration helps hub with determining what to open a pull request for. Otherwise, in some situations you need to explicitly set head and base via command-line flags.

I'm closing this since it seems none of you hit an actual bug in hub, but that you didn't use explicit base/head flags when you needed to. If you are strongly convinced that hub does something wrong in certain scenarios, please fill me in with more details.

@mislav mislav closed this as completed Jun 13, 2012
@mathiasbynens
Copy link

I’m currently having the same issue.

$ hub pull-request "Make generator scripts output data in the new format" -b "slevithan:master" -h "mathiasbynens:astral-support" -i 29
Error creating pull request: Unprocessable Entity (HTTP 422)

I have used git push -u origin astral-support to set up tracking (as mentioned by @sirkitree).

Relevant links:

Am I doing something wrong? I’ve used this exact same command successfully before.

@mislav
Copy link
Owner

mislav commented Jun 15, 2012

Is that the full error message?

You can only turn your own issues into pull requests; this is GitHub's limitation. This way you can't hijack other people's issues.

@mathiasbynens
Copy link

You can only turn your own issues into pull requests; this is GitHub's limitation. This way you can't hijack other people's issues.

Ah, that explains it. Last time I used it, it was an issue that I had created. Thanks!

Is that the full error message?

That’s the full error message, yes. Does GitHub provide more details in case of such an error? If so, it would be useful to have hub display those.

@mislav
Copy link
Owner

mislav commented Jun 15, 2012

That’s the full error message, yes. Does GitHub provide more details in case of such an error? If so, it would be useful to have hub display those.

hub should display that message. Make sure you have the latest version of hub.

@mathiasbynens
Copy link

Isn’t v1.10.1 the most recent version?

$ hub --version
git version 1.7.10.4
hub version 1.10.1

An empty line shows up below the “Error creating pull request: Unprocessable Entity (HTTP 422)” message. I guess that’s where the details would be if GitHub provided them, then?

@carsonkahn-outdated-account

@mathiasbynens 1.10.2 is now… Did y'all ever get this figured out?

@mislav
Copy link
Owner

mislav commented Sep 9, 2012

@mathiasbynens Seems like you tried to provide both subject line and issue number when opening a pull request. You can't do that (although that's probably not the cause of your problems)

The cause of your problem is likely that you don't own the issue in question. You can turn an issue to pull request if you don't own it yourself, or have admin right on the repo (I guess?)

I'll try to make better error messages, but I already tried to display the errors GitHub returns. Maybe they are simply not returning enough details in this case.

@ackalker
Copy link

Ran into the same issue just yet. Found an issue in a project, forked it, hacked up a fix proposal, wanted to add it to the issue. No dice.
I know that it is possible to reference issues in one's 'own' (fork of a) project in commit messages, I just don't know if it is possible to reference another project's issues (in particular a parent project of a fork) in my own commits.

@mislav
Copy link
Owner

mislav commented Oct 24, 2012

@ackalker See my comment. Your problem stems from the fact that you don't own the issue in question. I'll try to make the error message clearer about this.

@mrcasals
Copy link
Author

I just realised I didn't give any feedback.

I finally got my problem solved by doing hub pull-request -h <owner>:<current-branch>

@nelsonenzo
Copy link

I had the same problem as described at the very top of this thread, even when I specified the base and head explicitely. In my case, the problem was that it was trying to create a pull request based off my local branch, rather than the remote branch, even though it had been pushed. i.e.
hub pull-request "some description" -b companyName:master-fork -h macUserName:feature-branch
gave me:
Error creating pull request: Unprocessable Entity (HTTP 422)
Missing field: "head_sha"
Missing field: "base_sha"
No commits between companyName:master-fork and macUserName:feature-branch

The Fix: paying close attention and specifing the remote username of the branch I was trying to create a pull request from:
hub pull-request "some description" -b companyName:master-fork -h companyName:feature-branch

I'm sure there is a config not set quite right somewhere for me, but Im glad it works and hopefully this will help someone.

@matthew-brett
Copy link

I have the same issue running latest homebrew hub and xcode git:

$ hub --version
git version 1.8.3.4 (Apple Git-47)
hub version 1.11.2

Here's an example, although this happens for all my repos I've tested so far on this machine.

I have these remotes:

$ git remote -v
matthew git@github.com:matthew-brett/nibabel.git (fetch)
matthew git@github.com:matthew-brett/nibabel.git (push)
origin  git@github.com:nipy/nibabel.git (fetch)
origin  git@github.com:nipy/nibabel.git (push)

I make a branch, push to my repo, and make a pull request - always with same error:

$ git co -b hub-test-branch
Switched to a new branch 'hub-test-branch'
$ echo "Some text" > new_file
$ git add new_file
$ git commit -m "Add a new file for testing"
[hub-test-branch 02ca3ea] Add a new file for testing
1 file changed, 1 insertion(+)
create mode 100644 new_file
$ git push matthew hub-test-branch --set-upstream
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 298 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@github.com:matthew-brett/nibabel.git
* [new branch]      hub-test-branch -> hub-test-branch
Branch hub-test-branch set up to track remote branch hub-test-branch from matthew.
$ hub pull-request 
github.com username: matthew-brett
github.com password for matthew-brett (never stored): 
Error creating pull request: Unprocessable Entity (HTTP 422)

$ hub pull-request -b nipy:master
github.com username: matthew-brett
github.com password for matthew-brett (never stored): 
Error creating pull request: Unprocessable Entity (HTTP 422)

$ hub pull-request -b nipy:master -h matthew-brett:hub-test-branch
github.com username: matthew-brett
github.com password for matthew-brett (never stored): 
Error creating pull request: Unprocessable Entity (HTTP 422)

Here's the new (matthew-brett:hub-test-branch) and the previous (nipy:master) commits:

02ca3ea10361658859711c3a19567321c46122d3 Add a new file for testing
86f27381912ab7ccec20f325ae8f6426046d6695 RF: bdist_wheel, bdist_mpkg as setuptools commands

@matthew-brett
Copy link

My issue fixed by updating to hub version 1.12

@nvlimbachiya
Copy link

@matthew-brett I am experiencing similar issues with hub and getting HTTP 422 error when I make a pull-request to a remote repo. How did you upgrade hub to 1.12? I am using brew and it keeps complaining that there is none available. My git version is 1.9.0 and hub version is 1.11.2.

@matthew-brett
Copy link

I just did brew update and brew upgrade hub - does that work for you?

@mislav
Copy link
Owner

mislav commented Sep 20, 2016

@jerryasher Sorry you're having trouble!

  1. What is your hub version?
  2. What is your git config push.default?
  3. You can debug with HUB_VERBOSE=1 hub pull-request .... You will be able to see raw HTTP requests. What parameters is hub trying to post? What API endpoint is it trying to post to?

Sorry that this is such a mess right now. I'm working on making this easier. In the meantime, you can try using explicit head:

hub pull-request -h jerryasher:copy_file_metadata

@jerryasher
Copy link

Thanks, I won't be able to get back to this until Thursday, but I
appreciate the quick reply!

On Sep 20, 2016 4:02 PM, "Mislav Marohnić" notifications@github.com wrote:

@jerryasher https://github.com/jerryasher Sorry you're having trouble!

  1. What is your hub version?
  2. What is your git config push.default?
  3. You can debug with HUB_VERBOSE=1 hub pull-request .... You will be
    able to see raw HTTP requests. What parameters is hub trying to post? What
    API endpoint is it trying to post to?

Sorry that this is such a mess right now. I'm working on making this
easier. In the meantime, you can try using explicit head:

hub pull-request -h jerryasher:copy_file_metadata


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#189 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAosCV5ToTvOLQ2Uhc5NdLWcUHTv4qNpks5qsGX5gaJpZM4AA238
.

@jerryasher
Copy link

Okay, so getting back, and reading about about push.default, I do sort of think at least one issue is that my git config push.default is simple not current, but I'm also getting validation failed.

So

$ hub --version
git version 2.8.3
hub version 2.2.8

git config push.default is simple

And hub fails with:

> POST https://api.github.com/repos/getpelican/pelican/pulls
> Authorization: token [REDACTED]
{"base":"master","body":"Python's shutil.copy2 fails on Android when copying a file's meta data (perm bits, access times) onto certain filesystems.\nThis is documented as python issue28141 https://bugs.python.org/issue28141\n\nThese commits workaround that bug by\n\n+ creating a new function copy_file_metadata in utils.py\n+ wrapping calls to copy2 in a try/except clause that logs any errors that occur but keep execution going\n+ changing the calls to shutil.copy2 to calls to the new function","head":"jerryasher:copy_file_metadata","title":"Python's shutil.copy2 fails on Android"}
< HTTP 422
{"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"head","code":"invalid"}],"documentation_url":"https://developer.github.com/v3/pulls/#create-a-pull-request"}
Error creating pull request: Unprocessable Entity (HTTP 422)
Invalid value for "head"

The same validation error occurs even when I point to an explicit head.

Googling for hub authentication issues, I can't see anything I am doing/did wrong. I did login a few days back with hub. I do see a ~/.config/hub that seems to have a valid token for user: jerryasher and on github itself there is a token that is described as "hub for Jerry@mybox" that has enabled scopes: repo, repo:status, repo_deployment, public_repo

@mislav
Copy link
Owner

mislav commented Sep 23, 2016

The same validation error occurs even when I point to an explicit head.

Thanks for that debugging data. The parameters that hub tries to POST as a new pull request is perfectly valid. You are not able to create a pull request because, as it turns out, jerryasher/pelican isn't a fork of getpelican/pelican. I suggest you delete your pelican repo on GitHub, do hub fork, push your branch again (git push jerryasher HEAD), and try making a pull request again.

@jerryasher
Copy link

jerryasher/pelican isn't a fork of getpelican/pelican

Well that's an interesting statement! I admit I am a novice with git and github, but if I recall the pedigree of jerryasher/pelican, I cloned it from getpelican/pelican onto my local machine, setup the remotes, and then pushed onto github. I think that's what I did, but well I'm not sure.

Is that not a fork? Are you saying it's "merely" a clone, not a fork, and if so, what were you able to look at that let you know it was a clone (or whatever it is) and not a fork?

@jerryasher
Copy link

Heh. Okay, I bet amongst other things you were looking for this: forked from getpelican/pelican

@mislav
Copy link
Owner

mislav commented Sep 24, 2016

Sorry, I didn't know you were new to GitHub.

A "fork" can mean two things, depending on the context:

  1. You obtained an open source project and made changes to it. You've then created a "fork". Your changed version might not be public yet. You might choose to make it public (on a site like GitHub) or submit patches to the original maintainer(s).
  2. You have forked a repository on GitHub. This is done via the "fork" button on GitHub.com or hub fork command. It kind of encompasses (1), but with the addition of GitHub being aware that your fork is somehow "linked" to the parent repository. GitHub pull requests are only possible from a GitHub fork to the parent repo (or another fork), or within the same repo, but they are not available between repos which aren't "linked" as forks— even though they might share the same history in git, as in your case.

@isomorphisms
Copy link

I had this error too.

@oscardemoya
Copy link

It seems it won't accept the slash character (/) in branch name.

@minal2709
Copy link

git version 2.13.1
hub version 2.2.9

I get the same error. Error creating pull request: Unprocessable Entity (HTTP 422)

@TheAifam5
Copy link

yes, still the same error.

@mislav
Copy link
Owner

mislav commented Jul 4, 2017

Anyone who is still getting the Error creating pull request: Unprocessable Entity (HTTP 422) error:

  1. Does the error message provide any more information other than that single line?
  2. If you use HUB_VERBOSE=1 hub pull-request ... to enable verbose mode and inspect the raw JSON server response, does it contain any more information about what went wrong?

Thank you.

@ohcibi
Copy link

ohcibi commented Jul 7, 2017

@mislav I just had this because I forgot to push to my fork before hub pull-request. Maybe a TL;DR should added to the issue text. Main reasons why it fails:

  1. Forget to push to fork
  2. Forget to track fork'ed branch (i.e. git push -u <my-remote> <my-new-branch>)

@oblitum
Copy link

oblitum commented Oct 19, 2017

Does this still work, I tried all variations, all I can get is:

$ HUB_VERBOSE=1 hub pull-request -i 15 -h "oblitum:open-functionality"
$ git config alias.pull-request
$ git rev-parse -q --git-dir
$ git remote -v
$ git config --get-all hub.host
$ git config push.default
$ git rev-parse -q --git-path refs/remotes/oblitum/open-functionality
> GET https://api.github.com/repos/oblitum/extrakto
> Authorization: token [REDACTED]
< HTTP 401
{"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
$ git rev-list --cherry-pick --right-only --no-merges oblitum/open-functionality...
> POST https://api.github.com/repos/laktak/extrakto/pulls
> Authorization: token [REDACTED]
{"base":"master","head":"oblitum:open-functionality","issue":15}
< HTTP 401
{"message":"Bad credentials","documentation_url":"https://developer.github.com/v3"}
Error creating pull request: Unauthorized (HTTP 401)
Bad credentials
git version 2.14.2
hub version 2.2.9

@pranavgarg
Copy link

In my case, it was a simple mistake of not pushing the local branch to the remote origin.
Once I pushed the branch to GitHub was able to successfully create the pull-request using hub.

@fperez
Copy link

fperez commented Nov 18, 2017

Quick note: this happens very easily if one follows to the line the official instructions, because those suggest using:

# push the changes to your new remote
$ git push YOUR_USER feature

where as they should read:

# push the changes to your new remote
$ git push -u YOUR_USER feature

The -u flag is missing from the instructions. This has happened already to me three or four times, and I end up here every time. There may be other causes, but I suspect if the docs are updated with that trivial fix (add -u to that line), at least some people won't stumble on this anymore...

@mislav
Copy link
Owner

mislav commented Nov 20, 2017

@fperez Good catch. Mind submitting a fix for the gh-pages branch?

@lestephane
Copy link

Why was this closed? @fperez pointed out that the official instructions miss the crucial parameter (-u).
Looking at https://hub.github.com now, the flag is still missing:

# push the changes to your new remote
$ git push origin feature

I followed those instructions for the first time today, and, sure enough, got the 422, and landed on this issue...

@mislav
Copy link
Owner

mislav commented Jul 2, 2019

@lestephane Are you using the latest version of hub?

This should work:

$ git push origin HEAD
$ hub pull-request

If it doesn't, then please state some more info, such as git remote configuration and current git config push.default and git version. Thank you!

@lestephane
Copy link

lestephane commented Jul 3, 2019

This is what I have

$ hub --version
git version 2.21.0
hub version 2.12.1
$ git config push.default
upstream

My main concern is whether I can follow the instructions at https://hub.github.com without getting any error.

For my next PR I'll follow the instructions to the letter, and report more details if I still get the problem. Do you see any problem with my current versions and git config?

@mislav
Copy link
Owner

mislav commented Jul 3, 2019

@lestephane I'm sorry, but you'll have to share more info about your error. Hub does work (this is verified by automated tests) that git push origin HEAD (no -u) and hub pull-request flow works in a common-use case, but the reason it does not work for you might be that part of your workflow is more specific or that there is an edge-case bug.

What I want to know is:

  • How did you push the current branch before doing hub pull-request? I'm presuming it was git push <REMOTE> <BRANCH> or git push <REMOTE> HEAD.
  • What is the git remote configuration for REMOTE? See git remote -v) and anonymize the names of repositories if needed.
  • What is the configuration for remotes named origin, upstream, and github (if any)?
  • Are you pushing your branch to a GitHub repository that is a fork?
  • What is the exact error that you get as a result of hub pull-request? You can set HUB_VERBOSE=1 to get more debugging output.

Thank you!

@lestephane
Copy link

Here is the full reproduction showing that the instructions on https://hub.github.com/ for contributing "As a contributor to open-source" are not working for me. After the reproduction, I answer each of your questions in turn. the HUB_VERBOSE=1 output can be confusing with lines starting with dollar sign ($) which could be mistaken for commands I ran myself as part of the reproduction, so I put the verbose output at the very, very end of this comment.

Reproduction

$ hub --version
git version 2.21.0
hub version 2.12.1

$ grep "hub alias"  ~/.bashrc
eval "$(hub alias -s)"

$ git clone --depth 1 github/hub
Cloning into 'hub'...
remote: Enumerating objects: 676, done.
remote: Counting objects: 100% (676/676), done.
remote: Compressing objects: 100% (538/538), done.
remote: Total 676 (delta 162), reused 345 (delta 101), pack-reused 0
Receiving objects: 100% (676/676), 1.42 MiB | 635.00 KiB/s, done.
Resolving deltas: 100% (162/162), done.

$ git checkout -b feature
Switched to a new branch 'feature'

$ echo -e "\nnew stuff" >> README.md

$ git commit -am "done with feature"
[feature a08a79d] done with feature
 1 file changed, 2 insertions(+)

$ git fork --remote-name=origin
renaming existing "origin" remote to "upstream"
Updating origin
remote: Enumerating objects: 17667, done.
remote: Counting objects: 100% (17667/17667), done.
remote: Compressing objects: 100% (5670/5670), done.
remote: Total 17352 (delta 11605), reused 17010 (delta 11266), pack-reused 0
Receiving objects: 100% (17352/17352), 4.80 MiB | 641.00 KiB/s, done.
Resolving deltas: 100% (11605/11605), completed with 238 local objects.
From git://github.com/github/hub
 * [new branch]        1.11-stable             -> origin/1.11-stable
 * [new branch]        1.12-stable             -> origin/1.12-stable
 * [new branch]        2.2-stable              -> origin/2.2-stable
 * [new branch]        2.7-stable              -> origin/2.7-stable
...(full branch and tag listing here)
 * [new tag]           v2.8.0                  -> v2.8.0
 * [new tag]           v2.8.1                  -> v2.8.1
 * [new tag]           v2.8.2                  -> v2.8.2
 * [new tag]           v2.8.3                  -> v2.8.3
 * [new tag]           v2.8.4                  -> v2.8.4
 * [new tag]           v2.9.0                  -> v2.9.0
new remote: origin

$ git push origin feature
Enumerating objects: 22, done.
Counting objects: 100% (21/21), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 300 bytes | 100.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: 
remote: Create a pull request for 'feature' on GitHub by visiting:
remote:      https://github.com/lestephane/hub/pull/new/feature
remote: 
To github.com:lestephane/hub.git
 * [new branch]        feature -> feature

$ git pull-request
(edit the description in vim , then :wq)
Error creating pull request: Unprocessable Entity (HTTP 422)
Invalid value for "head"

$ git config -l | grep -v user.name | sort
alias.changes=log --name-status HEAD..
alias.up=pull --rebase --autostash
branch.master.merge=refs/heads/master
branch.master.remote=upstream
color.ui=auto
core.autocrlf=input
core.bare=false
core.editor=vim
core.excludesfile=/home/lestephane/.gitignore_global
core.filemode=true
core.logallrefupdates=true
core.repositoryformatversion=0
core.whitespace=cr-at-eol
credential.helper=/usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring
diff.tool=meld
http.postbuffer=52428800
merge.conflictstyle=diff3
merge.tool=meld
mergetool.meld.path=/usr/bin/meld
push.default=upstream
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git@github.com:lestephane/hub.git
remote.upstream.fetch=+refs/heads/master:refs/remotes/upstream/master
remote.upstream.url=git://github.com/github/hub.git
user.useconfigonly=true

$ git remote -vv
origin	git@github.com:lestephane/hub.git (fetch)
origin	git@github.com:lestephane/hub.git (push)
upstream	git://github.com/github/hub.git (fetch)
upstream	git://github.com/github/hub.git (push)

Answers to your questions

How did you push the current branch before doing hub pull-request?

The way it is described at https://hub.github.com/ for contributing "As a contributor to open-source", through the git alias

$ git push origin feature

What is the git remote configuration for REMOTE?

Included in the reproduction, restated here for convenience

$ git remote -vv
origin	git@github.com:lestephane/hub.git (fetch)
origin	git@github.com:lestephane/hub.git (push)
upstream	git://github.com/github/hub.git (fetch)
upstream	git://github.com/github/hub.git (push)

Are you pushing your branch to a GitHub repository that is a fork?

Yes, since I'm following the way it is described at https://hub.github.com/ for contributing "As a contributor to open-source", which says I should do

$ git fork --remote-name=origin`

Which I did (see reproduction)

What is the exact error that you get as a result of hub pull-request? You can set HUB_VERBOSE=1 to get more debugging output.

The output of $ HUB_VERBOSE=1 git pull-request is as follows:

$ git rev-parse -q --git-dir
$ git remote -v
$ git config --get-all hub.host
$ git config push.default
$ git rev-parse --symbolic-full-name feature@{upstream}
$ git config branch.feature.remote
$ git rev-parse -q --git-path refs/remotes/origin/feature
> GET https://api.github.com/repos/github/hub
> Authorization: token [REDACTED]
> Accept: application/vnd.github.v3+json;charset=utf-8
< HTTP 200
{"id":401025,"node_id":"MDEwOlJlcG9zaXRvcnk0MDEwMjU=","name":"hub","full_name":"github/hub","private":false,"owner":{"login":"github","id":9919,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5MTk=","avatar_url":"https://avatars1.githubusercontent.com/u/9919?v=4","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/github/hub","description":"A command-line tool that makes git easier to use with GitHub.","fork":false,"url":"https://api.github.com/repos/github/hub","forks_url":"https://api.github.com/repos/github/hub/forks","keys_url":"https://api.github.com/repos/github/hub/keys{/key_id}","collaborators_url":"https://api.github.com/repos/github/hub/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/github/hub/teams","hooks_url":"https://api.github.com/repos/github/hub/hooks","issue_events_url":"https://api.github.com/repos/github/hub/issues/events{/number}","events_url":"https://api.github.com/repos/github/hub/events","assignees_url":"https://api.github.com/repos/github/hub/assignees{/user}","branches_url":"https://api.github.com/repos/github/hub/branches{/branch}","tags_url":"https://api.github.com/repos/github/hub/tags","blobs_url":"https://api.github.com/repos/github/hub/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/github/hub/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/github/hub/git/refs{/sha}","trees_url":"https://api.github.com/repos/github/hub/git/trees{/sha}","statuses_url":"https://api.github.com/repos/github/hub/statuses/{sha}","languages_url":"https://api.github.com/repos/github/hub/languages","stargazers_url":"https://api.github.com/repos/github/hub/stargazers","contributors_url":"https://api.github.com/repos/github/hub/contributors","subscribers_url":"https://api.github.com/repos/github/hub/subscribers","subscription_url":"https://api.github.com/repos/github/hub/subscription","commits_url":"https://api.github.com/repos/github/hub/commits{/sha}","git_commits_url":"https://api.github.com/repos/github/hub/git/commits{/sha}","comments_url":"https://api.github.com/repos/github/hub/comments{/number}","issue_comment_url":"https://api.github.com/repos/github/hub/issues/comments{/number}","contents_url":"https://api.github.com/repos/github/hub/contents/{+path}","compare_url":"https://api.github.com/repos/github/hub/compare/{base}...{head}","merges_url":"https://api.github.com/repos/github/hub/merges","archive_url":"https://api.github.com/repos/github/hub/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/github/hub/downloads","issues_url":"https://api.github.com/repos/github/hub/issues{/number}","pulls_url":"https://api.github.com/repos/github/hub/pulls{/number}","milestones_url":"https://api.github.com/repos/github/hub/milestones{/number}","notifications_url":"https://api.github.com/repos/github/hub/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/github/hub/labels{/name}","releases_url":"https://api.github.com/repos/github/hub/releases{/id}","deployments_url":"https://api.github.com/repos/github/hub/deployments","created_at":"2009-12-05T22:15:25Z","updated_at":"2019-07-03T09:52:50Z","pushed_at":"2019-07-02T14:58:51Z","git_url":"git://github.com/github/hub.git","ssh_url":"git@github.com:github/hub.git","clone_url":"https://github.com/github/hub.git","svn_url":"https://github.com/github/hub","homepage":"https://hub.github.com/","size":6213,"stargazers_count":16573,"watchers_count":16573,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":1670,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":188,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1670,"open_issues":188,"watchers":16573,"default_branch":"master","permissions":{"admin":false,"push":false,"pull":true},"organization":{"login":"github","id":9919,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk5MTk=","avatar_url":"https://avatars1.githubusercontent.com/u/9919?v=4","gravatar_id":"","url":"https://api.github.com/users/github","html_url":"https://github.com/github","followers_url":"https://api.github.com/users/github/followers","following_url":"https://api.github.com/users/github/following{/other_user}","gists_url":"https://api.github.com/users/github/gists{/gist_id}","starred_url":"https://api.github.com/users/github/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/github/subscriptions","organizations_url":"https://api.github.com/users/github/orgs","repos_url":"https://api.github.com/users/github/repos","events_url":"https://api.github.com/users/github/events{/privacy}","received_events_url":"https://api.github.com/users/github/received_events","type":"Organization","site_admin":false},"network_count":1670,"subscribers_count":328}
$ git rev-list --cherry-pick --right-only --no-merges upstream/master...upstream/feature
$ git rev-parse --show-toplevel
$ git var GIT_EDITOR
$ git config core.commentchar
$ vim --cmd set ft=gitcommit tw=0 wrap lbr /home/lestephane/GitRepos/hub/.git/PULLREQ_EDITMSG
> POST https://api.github.com/repos/github/hub/pulls
> Authorization: token [REDACTED]
> Accept: application/vnd.github.shadow-cat-preview+json;charset=utf-8
{"base":"master","head":"github:feature","maintainer_can_modify":true,"title":"Please ignore this pull request, attempting to come up with the reproduction steps from the problem I experienced in #189"}
< HTTP 422
{"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"head","code":"invalid"}],"documentation_url":"https://developer.github.com/v3/pulls/#create-a-pull-request"}
Error creating pull request: Unprocessable Entity (HTTP 422)
Invalid value for "head"

@ohcibi
Copy link

ohcibi commented Jul 3, 2019

@Lestaphane you have to track your feature branch. It’s not a bug but a common error users do because of missing documentation.

git push -u origin your-branch

Instead of simply git push

@mislav
Copy link
Owner

mislav commented Jul 5, 2019

@ohcibi This is precisely what @lestephane is reporting here: we either have to fix the docs, or we shoud make hub work without the -u. But, I thought the latter already works. I will look deeper into this.

Thank you for the detailed reproduction steps! ❤️

@Sameshaik

This comment was marked as off-topic.

Repository owner locked as resolved and limited conversation to collaborators May 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.