Open peterldowns opened 3 months ago
So the check to ensure that the slice is not empty. If not the library will panic at this line.
copied, err := copyTemplate(v.Index(0))
But you're right, someSliceExist
should be outside the not-empty check.
@hgiasac ok, that makes sense, and it clarifies that my problem is probably due to something else. Thanks.
Do you have any idea why I would be getting this failure intermittently? Could it be because I'm re-using the result
object? I'm iterating through responses that have nested cursors, and I've been just re-using the same result
instance each time. I didn't think that it would matter, since deserialization usually totally overwrites the response struct.
Do you have any idea why I would be getting this failure intermittently? Could it be because I'm re-using the
result
object? I'm iterating through responses that have nested cursors, and I've been just re-using the sameresult
instance each time. I didn't think that it would matter, since deserialization usually totally overwrites the response struct.
We may need the graphql schema on the server to know.
I reproduced your use case and didn't see anything wrong with the response example that you sent. However, can you try this commit to see if it works https://github.com/hasura/go-graphql-client/pull/141
I'm seeing an intermittent failure right now where sometimes (inconsistently!) a Github Graphql API response fails to decode, resulting in an error like this:
This error is thrown in the deserialization code when
someSliceExist == false
. I'm curious if it's related to the changes in #102 — a PR that has no description, no tests, and changes something suspicious. If you look at that PR, it makes a change so that when there is a slice, but it's of zero length,someSliceExist == false
, whereas before this change,someSliceExist
would be set totrue
. I'm trying to understand why I'm seeing this error intermittently, which is always a red flag that something is horribly wrong, especially considering that the API response is valid JSON and seems to match what I am deserializing into (because it succeeds intermittently!)An example of the failure happening is when the API responds with:
and I'm trying to deserialize into a struct like this:
The actual call to
graphql
looks like this:Any ideas what's going on? I've worked around it for now by literally using the exact same query and struct, but using
ExecRaw
and decoding the JSON response myself. Doing this succeeds every time.Finally, I'll add that I was unable to reproduce the issue ever in a testcase calling into
jsonutil.UnmarshalGraphQL
. Here's my testcase that always passes (which is weird, because I'd expect this to fail):