System.InvalidOperationException in Sparrow.Json.ManualBlittableJsonDocumentBuilder

276 views
Skip to first unread message

Mark Zielinski

unread,
Aug 12, 2018, 5:27:41 PM8/12/18
to RavenDB - 2nd generation document database
Hi,

I'm encountering an exception in Sparrow.Json.ManualBlittableJsonDocumentBuilder.FinishWritingScalarValue when making a patch request to modify a field (which uses a custom JSON converter that I have registered with Raven).   

This exception is basically happening when I'm patching an update time field which is a NodaTime.Instant type, however my custom converter changes this to a DateTime UTC value when the data is serialized.   I'm using the latest 4.1 nightly client and it looks like this is an issue internal to Raven, but let me know if there is possibly something that I'm doing wrong on my end that is causing this.    The custom converter is working for everything else when reading and writing the values to the database just not with the patch operations.

System.InvalidOperationException: Cannot perform ReadValue when encountered the ReadObjectDocument state
   at Sparrow.Json.ManualBlittableJsonDocumentBuilder`1.ThrowIllegalStateException(ContinuationState state, String realOperation) in C:\Builds\RavenDB-4.1-Nightly\src\Sparrow\Json\ManualBlittableJsonDocumentBuilder.cs:line 566
   at Sparrow.Json.ManualBlittableJsonDocumentBuilder`1.FinishWritingScalarValue(BuildingState currentState) in C:\Builds\RavenDB-4.1-Nightly\src\Sparrow\Json\ManualBlittableJsonDocumentBuilder.cs:line 553
   at Sparrow.Json.ManualBlittableJsonDocumentBuilder`1.WriteValue(String value) in C:\Builds\RavenDB-4.1-Nightly\src\Sparrow\Json\ManualBlittableJsonDocumentBuilder.cs:line 464
   at Raven.Client.Json.BlittableJsonWriter.WriteValue(String value) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Json\BlittableJsonWriter.cs:line 292
   at Raven.Client.Json.Converters.JsonDateTimeISO8601Converter.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Json\Converters\JsonDateTimeISO8601Converter.cs:line 25
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.Serialization.JsonSerializerProxy.SerializeInternal(JsonWriter jsonWriter, Object value, Type rootType)
   at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value)
   at REDACTED.IAM.Server.Extensions.JsonConverterExtensions.InstantConverter.WriteJson(JsonWriter writer, Instant instant, JsonSerializer serializer) in C:\Users\REDACTED\Desktop\REDACTED\API\IAM\REDACTED.IAM.Server\Extensions\JsonConverterExtensions.cs:line 57
   at Newtonsoft.Json.JsonConverter`1.WriteJson(JsonWriter writer, Object value, JsonSerializer serializer)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.Serialize(JsonWriter jsonWriter, Object value)
   at Raven.Client.Json.TypeConverter.ToBlittableSupportedType(Object value, DocumentConventions conventions, JsonOperationContext context) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Json\TypeConverter.cs:line 80
   at Raven.Client.Json.TypeConverter.ToBlittableSupportedType(Object value, DocumentConventions conventions, JsonOperationContext context) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Json\TypeConverter.cs:line 61
   at Raven.Client.Documents.Operations.PatchRequest.ToJson(DocumentConventions conventions, JsonOperationContext context) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Documents\Operations\PatchRequest.cs:line 61
   at Raven.Client.Documents.Commands.Batches.PatchCommandData.ToJson(DocumentConventions conventions, JsonOperationContext context) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Documents\Commands\Batches\PatchCommandData.cs:line 30
   at Raven.Client.Documents.Commands.Batches.BatchCommand..ctor(DocumentConventions conventions, JsonOperationContext context, List`1 commands, BatchOptions options, TransactionMode mode) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Documents\Commands\Batches\BatchCommand.cs:line 36
   at Raven.Client.Documents.Session.Operations.BatchOperation.CreateRequest() in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Documents\Session\Operations\BatchOperation.cs:line 46
   at Raven.Client.Documents.Session.AsyncDocumentSession.SaveChangesAsync(CancellationToken token) in C:\Builds\RavenDB-4.1-Nightly\src\Raven.Client\Documents\Session\AsyncDocumentSession.cs:line 128
   at REDACTED.IAM.Server.Controllers.IamController.ChangePassword(ChangePasswordRequest request) in C:\Users\REDACTED\Desktop\REDACTED\API\IAM\REDACTED.IAM.Server\Controllers\IamController.cs:line 236

Mark

Oren Eini (Ayende Rahien)

unread,
Aug 13, 2018, 3:00:45 AM8/13/18
to ravendb
Can you send us a way to reproduce this? 

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Oren Eini (Ayende Rahien)

unread,
Aug 14, 2018, 10:18:16 AM8/14/18
to or...@ravendb.net, ravendb
Found a repro, will have a fix soon

Oren Eini (Ayende Rahien)

unread,
Aug 14, 2018, 10:23:43 AM8/14/18
to or...@ravendb.net, ravendb
Okay, the issue is when we expect to write an object, but you wrote a value, which is not expected.
I'm guessing that somewhere down the line you have a WriteStartObject that cause this, so I'll need the repro code to see what is going on there.

Mark Zielinski

unread,
Aug 14, 2018, 3:20:49 PM8/14/18
to RavenDB - 2nd generation document database
Hi,

Thanks for taking a look at this.   I'll e-mail an example over privately so you can reproduce it on your end.   I ended up moving away from using the patch operations and now I just use LoadAsync to load the object, then modify the values and call SaveChangesAsync and it works as expected without errors.

Mark
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Aug 15, 2018, 2:35:31 AM8/15/18
to ravendb
Okay, found the problem. We have a problem when trying to do custom serialization for patches, yes.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.

Oren Eini (Ayende Rahien)

unread,
Aug 15, 2018, 2:40:19 AM8/15/18
to or...@ravendb.net, ravendb
Fixed and will be in the next build. Thanks.
Reply all
Reply to author
Forward
0 new messages