Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.47k stars 4.8k forks source link

Search SDK: Deserializing response fails if it contains an ISO DateTime in a JSON array #2434

Closed brjohnstmsft closed 8 years ago

brjohnstmsft commented 8 years ago

(This issue was originally reported via User Voice; Copying it here since it's a bug report, not a feature request.)

Confusing error message in azure .net SDK (Object must implement IConvertible)

When we search with the page size 1000+ and the response content length exceeds Azure response limit of 16MB , we are getting 'Object must implement IConvertible; instead of the actual problem. This error occurs in IndexCleint class SearchAsync method

_indexClient.Documents.SearchAsync(searchText, sp);

brjohnstmsft commented 8 years ago

Some questions for the person who reported this bug:

cbaski commented 8 years ago

Thank you for your response. It's not 400 , it's a 200 response. We used fiddler and get all the raw data and saved the content to a file. It seems like this is not 16MB limitation issue. it seems like serialization issue... here is the inner exception details . Please let us know if you need more information from us.

at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token) at Microsoft.Azure.Search.Serialization.DocumentConverter.<>c.b__6_0(JToken t) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Microsoft.Azure.Search.Serialization.DocumentConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.Deserialize[T](JsonReader reader) at Microsoft.Azure.Search.Serialization.SearchResultConverter2.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject[T](String json, JsonSerializerSettings settings) at Microsoft.Azure.Search.DocumentsOperations.<DoContinueSearchWithHttpMessagesAsync>d__153.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Search.DocumentsOperationsExtensions.d13.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Alden.FacetSearchBase.SearchBase.d10.MoveNext() in E:\AgileDevelopment\Common\Alden.FacetSearch\Main\Alden.FacetSearchBase\SearchBase.cs:line 228 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Alden.FacetSearchBase.SearchBase.d__7.MoveNext() in SearchBase.cs:line 130

cbaski commented 8 years ago

When we set the page size to 1000 and retrieve all the retrievable fields we get this exception. On the other hand if we reduce the number of fields return to 3 or 4 basic fields ,we get a perfect response with no exception.

brjohnstmsft commented 8 years ago

Thanks for the details. We'll investigate.

brjohnstmsft commented 8 years ago

@cbaski I have a few follow-up questions.

What is the smallest response payload size for which you can reproduce this issue?

Would you be able to share the Fiddler trace for such a repro? You can email it to me (bruce dot johnston at the usual domain).

Thanks!

cbaski commented 8 years ago

Fiddler response content is emailed to your usual domain email. Please let me know , if you need anything else from me.

brjohnstmsft commented 8 years ago

The fix is now available in the latest preview SDK on NuGet. I'm still working on backporting it to the GA SDK.

brjohnstmsft commented 8 years ago

The fix is now available in the latest stable SDK on NuGet. Closing this issue.