422 Creating a new pull-request from upstream


#1

Hey folks,

I’ve been trying to build an integration that updates a forked repo branch from upstream once it detects changes there.

And I’ve been having issues creating pull-requests from upstream>fork that using the integration app token.

The endpoint I’m calling is https://developer.github.com/v3/pulls/#create-a-pull-request

And the parameters are:

{
	"title":"some title",
	"body": "some body",
	"head": "UPSTREAM_ORG:test",
	"base": "test"
}

The error I’m getting is:

{"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"not all refs are readable"}],"documentation_url":"https://developer.github.com/v3/pulls/#create-
a-pull-request"}

With code: 422, status: ‘Unprocessable Entity’.

I’ve tried the following;

  • Replacing the token with a personal token > works just fine.
  • Not specifying the remote repo org ( eg test instead of ORG:test ), ie when I’m creating a pull-request from a branch on the same repo. > works just fine
  • I’ve also tried assigning the app all possible permissions on both repos, the fork AND upstream one. > No dice.

Is this some sort of limitation ? Am I doing something wrong ?


#2

Hi @shadyvb, I’m having the same problem now. I’ve made a small github app that tries to create a PR into master (based on some event occurring). It works on a test public repo, and fails on a private repo.

I reached out to Github’s Support email; their response, over 3 weeks ago, was “we’ll get back to you in a week”, and despite further polite requests for an update they have ignored me since then.

Did you ever come to a solution, or determine what the problem was? Does anyone else have an idea of what’s going on?


#3

Unfortunately I couldn’t find what I was doing wrong, or any workaround. Still interested in making this happen though.


#4

Hi @shadyvb, I got a response about this problem from Github staff (I emailed them directly about six weeks ago). They solved it by having me give the app Repository Contents Read permission. Give it a shot?


#5

Thanks for following up @wraydulany! very much appreciated.

Will try it the soonest I have some time to dig up the app, and will report back.


#6

Apparently it wasn’t that, had those permissions all along.

I had to pass maintainer_can_modify as false for PR creation call, that made it work.

Ref: https://github.com/octokit/rest.js/issues/490


#7

Huh. Weird. But it’s working! Hooray!