GraphQL PullRequest query fails with wrong error message (Resource not accessible for commits) #137839
Unanswered
bahrmichael
asked this question in
API and Webhooks
Replies: 2 comments
-
As a workaround you can split out the |
Beta Was this translation helpful? Give feedback.
0 replies
-
We've seen this bug with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Select Topic Area
Bug
Body
I'm reporting that the PullRequest GraphQL query fails with
"errors":[{"type":"FORBIDDEN","path":["repository","pullRequest","commits","nodes",0],"extensions":{"saml_failure":false},"locations":[{"line":45,"column":5}],"message":"Resource not accessible by integration"}]
if I request theparticpants
, but succeeds if I don't requestparticipants
. The REST api doesn't seem to support the participants relation: https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#link-relationsThere are two bugs in here: (1) the misleading error message and (2) graphql being unable to serve data that can be accessed via the rest api
There are a lot of variables you need to consider, but I was able to reproduce this behavior reliably. I'll share a reproducer at the end of this report.
Bearer ...
) that is valid (i.e. it has been created in the last minute(s) and you don't get an error using it)Why don't you just use the GraphQL api for everything? Because the request to create signed commits needs the whole patch of the file instead of just the commit id, which becomes unfeasible with large changes.
I have also seen https://github.com/orgs/community/discussions/69154 and made sure that I'm not missing anything.
Reproducers
The reproducer is based on https://github.com/orgs/community/discussions/50055.
This assumes you have create a GitHub app with the required permissions (if you don't know which, then go for max permissions), installed it into the org of your GHE instance, and generate an installation access token.
Creating a signed commit
Run this first, and then run the other reproducer to see the error. This helps you avoid creating the commit over and over again (and I failed to extract the sha with jq).
Check out a repository from your GHE instance, modify a file, and create a commit. Don't push it.
Adjust the variables at the top of the file below, and run it.
Create a PR and access its commits (i.e. reproduce the bug)
Place the following
query.file
in your working directory:With the commit sha from the last script, adjust and run the following script. Close existing PRs if necessary.
When you run this, you should see that the REST call was able to read the commits, but the GraphQL returns an error saying that it can't access the commit.
Now close the PR you just created, remove the participants section from the
query.file
and run the script again. You'll see that it can now read the commits.I believe that other fields which were not part of the REST api but are part of GraphQL are also affected. We previously removed them from our queries to work around the same error: sourcegraph/sourcegraph-public-snapshot#64299
We dropped the following fields there:
Beta Was this translation helpful? Give feedback.
All reactions