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

Validation Failed when trying to create a new pull request #100

Open
Flameeyes opened this issue Mar 13, 2020 · 8 comments
Open

Validation Failed when trying to create a new pull request #100

Flameeyes opened this issue Mar 13, 2020 · 8 comments

Comments

@Flameeyes
Copy link
Contributor

@Flameeyes Flameeyes commented Mar 13, 2020

I've been trying to create a simple pull request for this very repository, by changing the README.rst file. When I just try git pull-request, and add my personal access token, I get the following:

running ['git', 'push', '-f', 'github', 'docs-update:docs-update']
Everything up-to-date
https://api.github.com:443 "GET /repos/Mergifyio/git-pull-request/pulls?base=master&head=flameeyes%3Adocs-update HTTP/1.1" 200 2
GET https://api.github.com/repos/Mergifyio/git-pull-request/pulls?base=master&head=flameeyes%3Adocs-update {'Authorization': 'Basic (login and password removed)', 'User-Agent': 'PyGithub/Python'} None ==> 200 {'date': 'Fri, 13 Mar 2020 19:04:25 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '2', 'server': 'GitHub.com', 'status': '200 OK', 'x-ratelimit-limit': '5000', 'x-ratelimit-remaining': '4963', 'x-ratelimit-reset': '1584127091', 'cache-control': 'private, max-age=60, s-maxage=60', 'vary': 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With', 'etag': '"2e4849080747ff77c2d51867d626c7c0"', 'x-oauth-scopes': 'repo', 'x-accepted-oauth-scopes': '', 'x-github-media-type': 'github.v3; format=json', 'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset', 'access-control-allow-origin': '*', 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 'x-frame-options': 'deny', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 'content-security-policy': "default-src 'none'", 'x-github-request-id': 'DA66:22CA1:329CC52:3B9B26D:5E6BD937'} []
running ['git', 'log', '--no-merges', '--format=%s', 'origin/master..docs-update']
running ['git', 'show', '-q', '--format=%b', 'docs-update', '--']
running ['git', 'var', 'GIT_EDITOR']
https://api.github.com:443 "POST /repos/Mergifyio/git-pull-request/pulls HTTP/1.1" 422 184
POST https://api.github.com/repos/Mergifyio/git-pull-request/pulls {'Authorization': 'Basic (login and password removed)', 'User-Agent': 'PyGithub/Python', 'Content-Type': 'application/json'} {"title": "Explicitly note how to use GitHub with 2FA.", "body": "This is a test pull request as well.", "base": "master", "head": "flameeyes:docs-update"} ==> 422 {'date': 'Fri, 13 Mar 2020 19:04:33 GMT', 'content-type': 'application/json; charset=utf-8', 'content-length': '184', 'server': 'GitHub.com', 'status': '422 Unprocessable Entity', 'x-ratelimit-limit': '5000', 'x-ratelimit-remaining': '4962', 'x-ratelimit-reset': '1584127091', 'x-oauth-scopes': 'repo', 'x-accepted-oauth-scopes': '', 'x-github-media-type': 'github.v3; format=json', 'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset', 'access-control-allow-origin': '*', 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 'x-frame-options': 'deny', 'x-content-type-options': 'nosniff', 'x-xss-protection': '1; mode=block', 'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 'content-security-policy': "default-src 'none'", 'vary': 'Accept-Encoding, Accept, X-Requested-With', 'x-github-request-id': 'DA66:22CA1:329D522:3B9B442:5E6BD939'} {"message":"Validation Failed","errors":[{"resource":"PullRequest","field":"head","code":"invalid"}],"documentation_url":"https://developer.github.com/v3/pulls/#create-a-pull-request"}
Unable to create pull request: Validation Failed (422)

I've tried giving the access token all the scopes, but that didn't help it either. As far as I can tell, that's not the problem anyway, given that https://developer.github.com/v3/#client-errors suggests this is an invalid field.

And as I'm typing this I see it says "field":"head","code":"invalid"

@jd

This comment has been minimized.

Copy link
Member

@jd jd commented Mar 13, 2020

Looks like you don't have a master branch on your repo, right?

@Flameeyes

This comment has been minimized.

Copy link
Contributor Author

@Flameeyes Flameeyes commented Mar 13, 2020

I do, according to https://github.com/Flameeyes/git-pull-request — since it's a fork.

And I have one locally because I cloned it, but I'm indeed trying git pull-request from a separate branch.

@jd

This comment has been minimized.

Copy link
Member

@jd jd commented Mar 16, 2020

Did you manage to create it in the end?
It makes little sense to me why GitHub refuses to create the PR the data seems valid:
{"title": "Explicitly note how to use GitHub with 2FA.", "body": "This is a test pull request as well.", "base": "master", "head": "flameeyes:docs-update"} AFAIU

@Flameeyes

This comment has been minimized.

Copy link
Contributor Author

@Flameeyes Flameeyes commented Mar 16, 2020

No, I tried this again with another repository, by letting git pull-request do the whole forking from scratch from master, but I still received the same error.

Did you test this with the Personal Access Token?

@jd

This comment has been minimized.

Copy link
Member

@jd jd commented Mar 16, 2020

I've been using this for years with a PAT and I'm not the only one. You'd get a 401 or 403 if you're token wouldn't be correct.
The error here is actually: {"resource":"PullRequest","field":"head","code":"invalid"}
Your head is invalid whereas flameeyes:docs-update seems valid to me… execpt if it's a case issue? should it be Flameeyes:docs-update?

@Flameeyes

This comment has been minimized.

Copy link
Contributor Author

@Flameeyes Flameeyes commented Mar 16, 2020

Good call! Indeed changing my username to Flameeyes with kwalletmanager did work.

Sigh should we report this up to GitHub?

@Flameeyes

This comment has been minimized.

Copy link
Contributor Author

@Flameeyes Flameeyes commented Mar 16, 2020

(I'm looking to add at least a workaround for this right now, stay tuned.)

@jd

This comment has been minimized.

Copy link
Member

@jd jd commented Mar 16, 2020

I don't think GitHub will fix that anytime soon. If there's a simpler workaround we can do (not too ugly), why not.

Flameeyes added a commit to Flameeyes/git-pull-request that referenced this issue Mar 16, 2020
…uest.

GitHub usernames are case-insensitive in _most_ contexts, but not all.

For example, one might login as `username`, while the "canonical" name is
`UserName`. But the pull requests need to be created with the correct
canonical case for the username.

This re-parses the repository as forked, and preserves the case of the user
(or org) name provided there.

See Issue Mergifyio#100 for details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.