mislav / hub

A command-line tool that makes git easier to use with GitHub.

Home Page:https://hub.github.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error creating pull request from issue

jpschewe opened this issue · comments

Command attempted:
hub pull-request -i 1072

What happened:
Error creating pull request: Unprocessable Entity (HTTP 422)
Invalid value for "base"

More info:

git version 2.34.1
hub version 2.14.2

VERBOSE data

$ git rev-parse -q --git-dir
$ git symbolic-ref HEAD
$ git remote -v
$ git config --get-all hub.host
> GET https://api.github.com/user
> Authorization: token [REDACTED]
> Accept: application/vnd.github.v3+json;charset=utf-8
< HTTP 200
< X-Oauth-Scopes: repo, write:discussion
{"login":"jpschewe","id":226585,"node_id":"MDQ6VXNlcjIyNjU4NQ==","avatar_url":"https://avatars.githubusercontent.com/u/226585?v=4","gravatar_id":"","url":"https://api.github.com/users/jpschewe","html_url":"https://github.com/jpschewe","followers_url":"https://api.github.com/users/jpschewe/followers","following_url":"https://api.github.com/users/jpschewe/following{/other_user}","gists_url":"https://api.github.com/users/jpschewe/gists{/gist_id}","starred_url":"https://api.github.com/users/jpschewe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpschewe/subscriptions","organizations_url":"https://api.github.com/users/jpschewe/orgs","repos_url":"https://api.github.com/users/jpschewe/repos","events_url":"https://api.github.com/users/jpschewe/events{/privacy}","received_events_url":"https://api.github.com/users/jpschewe/received_events","type":"User","site_admin":false,"name":"Jon Schewe","company":null,"blog":"http://mtu.net/~jpschewe","location":"Minneapolis, MN","email":"jpschewe@mtu.net","hireable":null,"bio":null,"twitter_username":null,"public_repos":35,"public_gists":4,"followers":13,"following":5,"created_at":"2010-03-20T02:40:11Z","updated_at":"2023-02-04T20:56:01Z"}
$ git symbolic-ref HEAD
$ git config push.default
$ git rev-parse -q --git-path refs/remotes/origin/issue/1072/team-finalist-schedule
$ git symbolic-ref refs/remotes/origin/HEAD
> GET https://api.github.com/repos/jpschewe/fll-sw
> Authorization: token [REDACTED]
> Accept: application/vnd.github.v3+json;charset=utf-8
< HTTP 200
< X-Oauth-Scopes: repo, write:discussion
< X-Accepted-Oauth-Scopes: repo
{"id":14289657,"node_id":"MDEwOlJlcG9zaXRvcnkxNDI4OTY1Nw==","name":"fll-sw","full_name":"jpschewe/fll-sw","private":false,"owner":{"login":"jpschewe","id":226585,"node_id":"MDQ6VXNlcjIyNjU4NQ==","avatar_url":"https://avatars.githubusercontent.com/u/226585?v=4","gravatar_id":"","url":"https://api.github.com/users/jpschewe","html_url":"https://github.com/jpschewe","followers_url":"https://api.github.com/users/jpschewe/followers","following_url":"https://api.github.com/users/jpschewe/following{/other_user}","gists_url":"https://api.github.com/users/jpschewe/gists{/gist_id}","starred_url":"https://api.github.com/users/jpschewe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpschewe/subscriptions","organizations_url":"https://api.github.com/users/jpschewe/orgs","repos_url":"https://api.github.com/users/jpschewe/repos","events_url":"https://api.github.com/users/jpschewe/events{/privacy}","received_events_url":"https://api.github.com/users/jpschewe/received_events","type":"User","site_admin":false},"html_url":"https://github.com/jpschewe/fll-sw","description":"FIRST Lego League scoring software","fork":false,"url":"https://api.github.com/repos/jpschewe/fll-sw","forks_url":"https://api.github.com/repos/jpschewe/fll-sw/forks","keys_url":"https://api.github.com/repos/jpschewe/fll-sw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jpschewe/fll-sw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jpschewe/fll-sw/teams","hooks_url":"https://api.github.com/repos/jpschewe/fll-sw/hooks","issue_events_url":"https://api.github.com/repos/jpschewe/fll-sw/issues/events{/number}","events_url":"https://api.github.com/repos/jpschewe/fll-sw/events","assignees_url":"https://api.github.com/repos/jpschewe/fll-sw/assignees{/user}","branches_url":"https://api.github.com/repos/jpschewe/fll-sw/branches{/branch}","tags_url":"https://api.github.com/repos/jpschewe/fll-sw/tags","blobs_url":"https://api.github.com/repos/jpschewe/fll-sw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jpschewe/fll-sw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jpschewe/fll-sw/git/refs{/sha}","trees_url":"https://api.github.com/repos/jpschewe/fll-sw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jpschewe/fll-sw/statuses/{sha}","languages_url":"https://api.github.com/repos/jpschewe/fll-sw/languages","stargazers_url":"https://api.github.com/repos/jpschewe/fll-sw/stargazers","contributors_url":"https://api.github.com/repos/jpschewe/fll-sw/contributors","subscribers_url":"https://api.github.com/repos/jpschewe/fll-sw/subscribers","subscription_url":"https://api.github.com/repos/jpschewe/fll-sw/subscription","commits_url":"https://api.github.com/repos/jpschewe/fll-sw/commits{/sha}","git_commits_url":"https://api.github.com/repos/jpschewe/fll-sw/git/commits{/sha}","comments_url":"https://api.github.com/repos/jpschewe/fll-sw/comments{/number}","issue_comment_url":"https://api.github.com/repos/jpschewe/fll-sw/issues/comments{/number}","contents_url":"https://api.github.com/repos/jpschewe/fll-sw/contents/{+path}","compare_url":"https://api.github.com/repos/jpschewe/fll-sw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jpschewe/fll-sw/merges","archive_url":"https://api.github.com/repos/jpschewe/fll-sw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jpschewe/fll-sw/downloads","issues_url":"https://api.github.com/repos/jpschewe/fll-sw/issues{/number}","pulls_url":"https://api.github.com/repos/jpschewe/fll-sw/pulls{/number}","milestones_url":"https://api.github.com/repos/jpschewe/fll-sw/milestones{/number}","notifications_url":"https://api.github.com/repos/jpschewe/fll-sw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jpschewe/fll-sw/labels{/name}","releases_url":"https://api.github.com/repos/jpschewe/fll-sw/releases{/id}","deployments_url":"https://api.github.com/repos/jpschewe/fll-sw/deployments","created_at":"2013-11-11T02:28:50Z","updated_at":"2022-12-14T22:27:22Z","pushed_at":"2023-02-04T22:23:30Z","git_url":"git://github.com/jpschewe/fll-sw.git","ssh_url":"git@github.com:jpschewe/fll-sw.git","clone_url":"https://github.com/jpschewe/fll-sw.git","svn_url":"https://github.com/jpschewe/fll-sw","homepage":"","size":842549,"stargazers_count":12,"watchers_count":12,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"has_discussions":false,"forks_count":7,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":116,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"allow_forking":true,"is_template":false,"web_commit_signoff_required":false,"topics":[],"visibility":"public","forks":7,"open_issues":116,"watchers":12,"default_branch":"main","permissions":{"admin":true,"maintain":true,"push":true,"triage":true,"pull":true},"temp_clone_token":"","allow_squash_merge":true,"allow_merge_commit":true,"allow_rebase_merge":true,"allow_auto_merge":false,"delete_branch_on_merge":false,"allow_update_branch":false,"use_squash_pr_title_as_default":false,"squash_merge_commit_message":"COMMIT_MESSAGES","squash_merge_commit_title":"COMMIT_OR_PR_TITLE","merge_commit_message":"PR_TITLE","merge_commit_title":"MERGE_MESSAGE","security_and_analysis":{"secret_scanning":{"status":"disabled"},"secret_scanning_push_protection":{"status":"disabled"}},"network_count":7,"subscribers_count":6}
$ git rev-list --cherry-pick --right-only --no-merges origin/issue/1072/team-finalist-schedule...
> POST https://api.github.com/repos/jpschewe/fll-sw/pulls
> Authorization: token [REDACTED]
> Accept: application/vnd.github.shadow-cat-preview+json;charset=utf-8
{"base":"master","head":"jpschewe:issue/1072/team-finalist-schedule","issue":1072,"maintainer_can_modify":true}
< HTTP 422
< X-Oauth-Scopes: repo, write:discussion
{"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"base","code":"invalid"}],"documentation_url":"https://docs.github.com/rest/reference/pulls#create-a-pull-request"}

Looking at the comments in #189 I'm wondering if my configuration of push.default is the problem

git config push.default
nothing

I have this set so that I need to be explicit on what I push. Perhaps this setting isn't compatible with hub.

When I add "-b main" to the command line it works fine.

I faced this issue many time already, this is due to the local origin/HEAD in your git repository to hold a different value than the actual upstream origin/HEAD (aka default branch on github)

I solved this by running the following command

$ git remote set-head origin -a
origin/HEAD set to main

This actually update the local ref origin/HEAD with the value from the remote repositoriy. Unfortunately this ref is not updated along with other refs when using git fetch.
More details at : https://www.jvt.me/posts/2021/03/31/git-origin-head/

@TheoBrigitte that works well for me, thank you.