octokit.graphql.net
octokit.graphql.net copied to clipboard
NullReferenceException when API quota is exceeded
Update: The issue seems to be independent of the query and occurs when the API rate limit is exceeded.
When executing this query:
var query = new Query()
.Organization(orgName)
.Team(Var("teamSlug"))
.Repositories(first: 100, after: Var("after"))
.Select(connection => new
{
connection.PageInfo.EndCursor,
connection.PageInfo.HasNextPage,
connection.TotalCount,
Items = connection.Edges.Select(e => new
{
e.Node.Name,
e.Permission
}).ToList(),
}).Compile();
var result = new List<CachedTeamAccess>();
foreach (var teamSlug in teamSlugs)
{
var vars = new Dictionary<string, object>
{
{ "after", null },
{ "teamSlug", teamSlug },
};
var current = await Connection.Run(query, vars);
vars["after"] = current.HasNextPage ? current.EndCursor : null;
while (vars["after"] != null)
{
var page = await Connection.Run(query, vars);
current.Items.AddRange(page.Items);
vars["after"] = page.HasNextPage
? page.EndCursor
: null;
}
I sometimes get the following exceptions:
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Octokit.GraphQL.Core.Deserializers.ResponseDeserializer.DeserializeException(JToken error)
at Octokit.GraphQL.Core.Deserializers.ResponseDeserializer.Deserialize[TResult](Func`2 deserialize, JObject data)
at Octokit.GraphQL.Core.SimpleQuery`1.Runner.<RunPage>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Octokit.GraphQL.ConnectionExtensions.<Run>d__2`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.DotnetOrg.GitHubCaching.CacheLoader.<GetCachedTeamAccessAsync>d__15.MoveNext() in D:\a\1\s\src\Microsoft.DotnetOrg.GitHubCaching\CacheLoader.cs:line 260
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Octokit.GraphQL.Core.Deserializers.ResponseDeserializer.DeserializeException(JToken error)
at Octokit.GraphQL.Core.Deserializers.ResponseDeserializer.Deserialize[TResult](Func`2 deserialize, JObject data)
at Octokit.GraphQL.Core.SimpleQuery`1.Runner.<RunPage>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Octokit.GraphQL.ConnectionExtensions.<Run>d__2`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.DotnetOrg.GitHubCaching.CacheLoader.<GetCachedMembersAsync>d__16.MoveNext() in D:\a\1\s\src\Microsoft.DotnetOrg.GitHubCaching\CacheLoader.cs:line 309
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.DotnetOrg.GitHubCaching.CacheLoader.<LoadAsync>d__10.MoveNext() in D:\a\1\s\src\Microsoft.DotnetOrg.GitHubCaching\CacheLoader.cs:line 43
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.DotnetOrg.PolicyCop.Commands.CacheOrgCommand.<ExecuteAsync>d__7.MoveNext() in D:\a\1\s\src\policop\Commands\CacheOrgCommand.cs:line 38
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.DotnetOrg.PolicyCop.Program.<Main>d__0.MoveNext() in D:\a\1\s\src\policop\Program.cs:line 73
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.DotnetOrg.PolicyCop.Program.<Main>(String[] args)
Any ideas?
@terrajobst,
Any idea which element is coming up null? You could try adding some guards like this:
Items = connection.Edges.Select(e => new
{
Name = e.Node != null ? e.Node.Name : null,
e.Permission
}).ToList(),
I don't think we can use e.Node?.Name
because it's an expression.
No, I've got zero idea and it very much nether repros locally :(
But by looking at the stack trace I'm inclined to say that bug isn't the schema but somewhere in your deserializer...
Update: The issue seems to be independent of the query and occurs when the API rate limit is exceeded.
👋 Hey Friends, this issue has been automatically marked as stale
because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned
label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!