Skip to content

System.Text.Json.JsonException when parsing response from SendMutationAsync. #628

Open
@sannidha

Description

@sannidha

We have recently upgraded our project to .Net 7 and we have started seeing this issue. We are using version 6.0.2.
but the json response looked fine.
Response:
{"data":{"provisionSsoUser":{"user":{"id":"d48656b8-c5a2-42f4-be2b-62f5e647c90f"}}}}

Code as below:

 var client = new GraphQLHttpClient(
     x =>
     {
         x.EndPoint = _graphQlEndpoint;
         x.HttpMessageHandler = new LoggingHandler(new HttpClientHandler());
     },
     new DebugSerializer());
 client.HttpClient.DefaultRequestHeaders.Add("Authorization", $"PSK {_graphQlPsk}");

 var provisionSsoUserRequest = new GraphQLRequest
     {
         Query = GraphQl.ProvisionSsoUser,
         OperationName = "ProvisionSsoUser",
         Variables = new { input = new { email = "[email protected]", name = "FullName", cw1OrganizationCode = "Code" } }
     };


// Exception thrown at this line.
 var response = await client.SendMutationAsync(provisionSsoUserRequest, () => new { provisionSsoUser = new { user = new { id = Guid.Empty } } });

StackTrace as below:

System.Text.Json.JsonException: The converter 'GraphQL.Client.Serializer.SystemTextJson.ImmutableConverter' read too much or not enough. Path: $ | LineNumber: 0 | BytePositionInLine: 9.
at System.Text.Json.ThrowHelper.ThrowJsonException_SerializationConverterRead(JsonConverter converter)
at System.Text.Json.Serialization.JsonConverter1.VerifyRead(JsonTokenType tokenType, Int32 depth, Int64 bytesConsumed, Boolean isValueConverter, Utf8JsonReader& reader) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.Serialization.JsonConverter1.ReadCoreAsObject(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo, ReadStack& state)
at System.Text.Json.JsonSerializer.Read[TValue](Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
at GraphQL.Client.Serializer.SystemTextJson.ImmutableConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in //src/GraphQL.Client.Serializer.SystemTextJson/ImmutableConverter.cs:line 68
at System.Text.Json.Serialization.Converters.CastingConverter2.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.ReadFromStreamAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken)
at GraphQL.Client.Http.GraphQLHttpClient.SendHttpRequestAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken) in /
/src/GraphQL.Client/GraphQLHttpClient.cs:line 129
at GraphQL.Client.Http.GraphQLHttpClient.SendQueryAsync[TResponse](GraphQLRequest request, CancellationToken cancellationToken) in /_/src/GraphQL.Client/GraphQLHttpClient.cs:line 81

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions