Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodaTime projection deserialization exception #2866

Open
jposert opened this issue Dec 16, 2023 · 1 comment
Open

NodaTime projection deserialization exception #2866

jposert opened this issue Dec 16, 2023 · 1 comment
Milestone

Comments

@jposert
Copy link

jposert commented Dec 16, 2023

Hello everyone. When trying to use NodaTime along with the project, I receive an exception:

System.Text.Json.JsonException: Cannot convert value to NodaTime.Instant
 ---> NodaTime.Text.UnparsableValueException: The value string does not match a quoted string in the pattern. Value being parsed: '2023-12-16T22:49:58.999361^+00:00'. (^ indicates error position.)
   at NodaTime.Text.ParseResult`1.GetValueOrThrow()
   at NodaTime.Text.ParseResult`1.get_Value()
   at NodaTime.Serialization.SystemTextJson.NodaPatternConverter`1.ReadJsonImpl(Utf8JsonReader& reader, JsonSerializerOptions options)
   at NodaTime.Serialization.SystemTextJson.NodaConverterBase`1.Read(Utf8JsonReader& reader, Type objectType, JsonSerializerOptions options)
   --- End of inner exception stack trace ---
   at NodaTime.Serialization.SystemTextJson.NodaConverterBase`1.Read(Utf8JsonReader& reader, Type objectType, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Converters.SmallObjectWithParameterizedConstructorConverter`5.TryRead[TArg](ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo, TArg& arg)
   at System.Text.Json.Serialization.Converters.SmallObjectWithParameterizedConstructorConverter`5.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.ReadConstructorArgumentsWithContinuation(ReadStack& state, Utf8JsonReader& reader, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
   at Marten.Services.SystemTextJsonSerializer.FromJsonAsync[T](Stream stream, CancellationToken cancellationToken)
   at Marten.Services.SystemTextJsonSerializer.FromJsonAsync[T](DbDataReader reader, Int32 index, CancellationToken cancellationToken)
   at Marten.Services.SystemTextJsonSerializer.FromJsonAsync[T](DbDataReader reader, Int32 index, CancellationToken cancellationToken)
   at Marten.Linq.Selectors.SerializationSelector`1.ResolveAsync(DbDataReader reader, CancellationToken token)
   at Marten.Linq.QueryHandlers.ListQueryHandler`1.HandleAsync(DbDataReader reader, IMartenSession session, CancellationToken token)
   at Marten.Linq.MartenLinqQueryProvider.ExecuteHandlerAsync[T](IQueryHandler`1 handler, CancellationToken token)
   at Marten.Linq.MartenLinqQueryProvider.ExecuteHandlerAsync[T](IQueryHandler`1 handler, CancellationToken token)
   at JasperFx.Core.Exceptions.ExceptionTransformExtensions.TransformAndThrow(IEnumerable`1 transforms, Exception ex)
   at JasperFx.Core.Exceptions.ExceptionTransforms.TransformAndThrow(Exception ex)
   at Marten.Exceptions.MartenExceptionTransformer.WrapAndThrow(Exception exception)
   at Marten.Linq.MartenLinqQueryProvider.ExecuteHandlerAsync[T](IQueryHandler`1 handler, CancellationToken token)
   at Marten.Linq.MartenLinqQueryable`1.ToListAsync[TResult](CancellationToken token)
...

I found an issue that probably concerns exactly the same thing #1276 - is it possible that the error has started occurring again?
As I already mentioned, the problem occurs only in the case when I use the Select projection - when I retrieve the whole document, deserialization works correctly.
The Marten configuration looks as follows:

options.UseDefaultSerialization(
    serializerType: SerializerType.SystemTextJson
);
options.UseNodaTime();

Tested with:
Marten: 6.4.0 / 7.0.0-beta.2
NodaTime: 3.1.9
Npgsql: 8.0.0

@jeremydmiller
Copy link
Member

Also see:

[Theory]
[InlineData(SerializerType.SystemTextJson)]
[InlineData(SerializerType.Newtonsoft)]
public void bug_1276_can_select_instant(SerializerType serializerType)
{
    return; // TODO -- FIX THIS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants