Closed spxtr closed 7 years ago
Thanks a lot for reporting this. I suspect this could be a bug in jsonutil
on some particular edge case. That's where the error comes from.
Quick question, are you using the latest version of githubql
(and its dependencies)? Or something older?
I will try to reproduce it, investigate it, and fix it if it's a bug on my side.
Thanks for the quick response. I'm using https://github.com/shurcooL/githubql/commit/b3091cd0b2f573f6945eb6f15b0559c06330a1a8 and https://github.com/shurcooL/graphql/commit/52ce28a2c9fdfbdb3377232422c7915fa04b678a.
Thanks. I can reproduce with latest. Most likely it's a bug in jsonutil
. I'll investigate and post updates.
This was indeed a bug in jsonutil
. It was not able to handle this query because there was a slice of nodes inside an inline fragment. I missed that edge case in #15. As I wrote there:
This is a large and riskier-than-usual PR. It replaces the extremely well-tested
encoding/json
unmarshaler with a brand new that was implemented over the last few days for the custom needs ofgraphql
: to unmarshal a JSON-encoded GraphQL server response into a query data structure. So there's a chance of edge cases that are not going to be handled.
That's what happened here.
This is now fixed via https://github.com/shurcooL/graphql/commit/68e5b1b3ab56633e42939506bc61f0b9fb2b7a79. I've also added a test so this won't regress.
You should see the problem go away after updating to the latest version:
go get -u github.com/shurcooL/githubql
(Or equivalent if you're using vendoring.)
The test program you provided no longer prints an error. I modified it slightly to print the query result to stdout as JSON:
Of the two following queries, the first succeeds and the second spits up an error. I spent a while adding debug printfs in graphql/internal/jsonutil but I wasn't able to figure it out. All I know is that the
Commits
object in the second query causes the problem. Removing that object and replacing it with something else in the PR works fine.Let me know if you need more info :)