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

Invalid URI: The Uri string is too long #645

Open
AlexTokar opened this issue Aug 9, 2019 · 1 comment
Open

Invalid URI: The Uri string is too long #645

AlexTokar opened this issue Aug 9, 2019 · 1 comment
Assignees

Comments

@AlexTokar
Copy link

  • Algolia Client Version: 6.2.0

When a quite long string is put to Filters property of Query object, it throws Invalid URI: The Uri string is too long exception during serialization. Here is a stack trace:

   at System.UriHelper.EscapeString(String input, Int32 start, Int32 end, Char[] dest, Int32& destPos, Boolean isUriString, Char force1, Char force2, Char rsvd)
   at System.Uri.EscapeDataString(String stringToEscape)
   at Algolia.Search.Utils.QueryStringHelper.<>c__DisplayClass1_0`1.<ToQueryString>b__1(PropertyInfo p)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.ConcatNIterator`1.LazyToArray()
   at System.Linq.Enumerable.ConcatNIterator`1.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Algolia.Search.Utils.QueryStringHelper.ToQueryString[T](T value, String[] ignoreList)
   at Algolia.Search.Serializer.QueryConverter.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.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, 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 Algolia.Search.Serializer.SerializerHelper.Serialize[T](T data, Stream stream, JsonSerializerSettings settings)
   at Algolia.Search.Transport.HttpTransport.CreateRequestContent[T](T data)
   at Algolia.Search.Transport.HttpTransport.ExecuteRequestAsync[TResult,TData](HttpMethod method, String uri, CallType callType, TData data, RequestOptions requestOptions, CancellationToken ct)
   at Algolia.Search.Clients.SearchClient.MultipleQueriesAsync[T](MultipleQueriesRequest request, RequestOptions requestOptions, CancellationToken ct)```

The usage of Uri.EscapeDataString in this method
https://github.com/algolia/algoliasearch-client-csharp/blob/5e79898740de9c31f0bff7199a6d00cd1079c04d/src/Algolia.Search/Utils/QueryStringHelper.cs#L81 causes the issue since it has some limitations of its length.


@Ant-hem
Copy link
Member

Ant-hem commented Aug 12, 2019

Hi! Thanks for the reporting the issue. I'll have a look at it in the coming days.

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

No branches or pull requests

3 participants