Open terrajobst opened 4 years ago
Hi @terrajobst 👋
There appears to be strange things going on with PAT scopes and what the GraphQL query returns.
I've created a repository here with your repro: https://github.com/jcansdale-test/terrajobst-issue-234
When a use a PAT with no scopes, I see the same exception as you: https://github.com/jcansdale-test/terrajobst-issue-234/runs/828496722?check_suite_focus=true#step:4:76
When I run the same query with a repo scoped PAT, it works fine: https://github.com/jcansdale-test/terrajobst-issue-234/runs/828498317?check_suite_focus=true#step:4:76
There appears to be some information missing when a no-scope PAT is used. 😕
This can be fixed with the following null check: https://github.com/jcansdale-test/terrajobst-issue-234/pull/1/files
Unfortunately this doesn't make it with with the default ${{ secrets.GITHUB_TOKEN }}
, which makes it throw a different exception:
System.AggregateException: One or more errors occurred. (Resource not accessible by integration) (Resource not accessible by integration)
---> Octokit.GraphQL.Core.Deserializers.ResponseDeserializerException: Resource not accessible by integration
--- End of inner exception stack trace ---
at Octokit.GraphQL.Core.Deserializers.ResponseDeserializer.Deserialize(String data)
at Octokit.GraphQL.Core.PagedQuery`1.Runner.RunPage(CancellationToken cancellationToken)
at Octokit.GraphQL.ConnectionExtensions.Run[T](IConnection connection, ICompiledQuery`1 query, Dictionary`2 variables, CancellationToken cancellationToken)
at Program.Main() in /home/runner/work/terrajobst-issue-234/terrajobst-issue-234/Program.cs:line 57
---> (Inner Exception #1) Octokit.GraphQL.Core.Deserializers.ResponseDeserializerException: Resource not accessible by integration<---
If you're running this from a GitHub Actions workflow, you could simply embed a no-scope PAT in the code. GitHub will automatically delete any scoped PATs pushed to a public repository, but it will leave no-scope PATs alone. 🙂
A no-scope PAT should be able to access all public information. I'll ping the API team about this tomorrow and see if they know what's going on!
For reference, here is the query that it having problems:
query {
repository(name: "runtime", owner: "dotnet") {
id
issues(filterBy: {
assignee: "*",createdBy: null,labels: null,mentioned: null,milestone: "*",since: "2020-06-26T09:30:00+01:00",states: null,viewerSubscribed: null
}, first: 100) {
pageInfo {
hasNextPage
endCursor
}
nodes {
id
owner: repository {
owner {
login
}
}
repo: repository {
name
}
number
title
createAt: createdAt
author {
login
}
state
url
timelineItems(since: "2020-06-26T09:30:00+01:00", first: 100) {
pageInfo {
hasNextPage
endCursor
}
nodes {
__typename
... on IssueComment {
createdAt
}
... on LabeledEvent {
createdAt
}
... on ClosedEvent {
createdAt
}
}
}
}
}
}
}
It works fine in https://developer.github.com/v4/explorer/ but no-scope and GitHub Actions tokens trip it up. 😢
There appears to be strange things going on with PAT scopes and what the GraphQL query returns.
I've created a repository here with your repro: https://github.com/jcansdale-test/terrajobst-issue-234
When a use a PAT with no scopes, I see the same exception as you: https://github.com/jcansdale-test/terrajobst-issue-234/runs/828496722?check_suite_focus=true#step:4:76
In my case, I was using an OAuth2 token with the read:org
scope. I've since added repo
scope because I need to write as well. However, not all authenticated users will have write access to the repos the query is executed against. I still need those results to be reliable/complete though.
Your workaround only solved part of the issue; I don't seem to get complete query results. Something causes the query to exclude issues; maybe there is another issue with the IssuesFilter
(#235)?
@terrajobst,
However, not all authenticated users will have write access to the repos the query is executed against. I still need those results to be reliable/complete though.
I think there are only a few event types missing. For example, any ReadColumnsInProjectEvent
will come up null. Is this an important one for you?
Your workaround only solved part of the issue; I don't seem to get complete query results. Something causes the query to exclude issues; maybe there is another issue with the IssuesFilter (#235)?
If you run the following query in https://developer.github.com/v4/explorer/, do you notice any missing issue?
query {
repository(name: "runtime", owner: "dotnet") {
issues(first: 100) {
nodes
{
number title
}
}
}
}
I think there are only a few event types missing. For example, any
ReadColumnsInProjectEvent
will come up null. Is this an important one for you?
No, the only important ones are the ones that I Switch
-ed over.
If you run the following query in https://developer.github.com/v4/explorer/, do you notice any missing issue?
Nope, the query result looks good to me.
This issue seams not to be resolved? I have encountered the very same thing recently.
Repro
This query crashes. The involved repo is public, so you should be able to repro it from your end.
Code
```xmlExpected behavior
The query succeeds.
Actual behavior
The query crashes
System.InvalidOperationException
: