SearchResponse deserialization fails when using PercentilesAggregation
Closed this issue ยท 13 comments
Elastic.Clients.Elasticsearch version: 9.0.6
Elasticsearch version: 9.0.1 (Hosted)
.NET runtime version: net9.0
Operating system version: Windows 11 (Client)
Description of the problem including expected versus actual behavior:
When calling SearchAsync using PercentilesAggregation on a FloatNumber field, an exception is thrown indicating that deserialization of the response failed. See stack trace in DebugInformation.
It seems like the JsonReader is attempting to read an Int64 whereas the actual value in the JSON string is a Single.
Example aggregation:
new PercentilesAggregation()
{
Field = "deliveryTime",
Percents = [ 50D ],
};Steps to reproduce:
- Call
SearchAsyncusingPercentilesAggregationon a FloatNumber field.
Expected behavior
Deserialization to succeed.
Provide DebugInformation (if relevant):
# FailureReason: Unrecoverable/Unexpected BadRequest while attempting POST on https://truncated.es.australia-southeast1.gcp.elastic-cloud.com/truncated/_search?routing=demo&typed_keys=true
- [1] BadRequest: Node: https://truncated.es.australia-southeast1.gcp.elastic-cloud.com/ Exception: JsonException Took: 00:00:03.2953294
# Audit exception in step 1 BadRequest:
System.Text.Json.JsonException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse`1[System.Object]. Path: $ | LineNumber: 0 | BytePositionInLine: 5295.
---> System.FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int64.
at System.Text.Json.ThrowHelper.ThrowFormatException(NumericType numericType)
at System.Text.Json.Utf8JsonReader.GetInt64()
at Elastic.Clients.Elasticsearch.Serialization.StringifiedLongConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\StringifiedConverters.cs:line 81
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__12`2.<ReadUnionValue>b__12_1(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 406
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.ReadUnionValue[T1,T2](Utf8JsonReader& reader, JsonSerializerOptions options, JsonUnionSelectorFunc selector, JsonReadFunc`1 readType1, JsonReadFunc`1 readType2) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 406
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.<>c.<Read>b__0_3(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.ReadDictionaryValue[TKey,TValue](Utf8JsonReader& reader, JsonSerializerOptions options, JsonReadFunc`1 readKey, JsonReadFunc`1 readValue) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 325
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.<>c.<Read>b__0_1(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__16`1.<TryReadProperty>b__16_0(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 502
at Elastic.Clients.Elasticsearch.Aggregations.TDigestPercentilesAggregateConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\TDigestPercentilesAggregate.g.cs:line 43
at Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(Utf8JsonReader& reader, JsonSerializerOptions options, String& name, IAggregate& value) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\AggregateDictionary.g.cs:line 126
at Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\AggregateDictionary.g.cs:line 34
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__16`1.<TryReadProperty>b__16_0(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 502
at Elastic.Clients.Elasticsearch.SearchResponseConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Api\SearchResponse.g.cs:line 62
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, T& value, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, T& value)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
at Elastic.Transport.Products.Elasticsearch.ElasticsearchResponseBuilder.SetBodyCoreAsync[TResponse](Boolean isAsync, ApiCallDetails details, BoundConfiguration boundConfiguration, Stream responseStream, CancellationToken cancellationToken)
at Elastic.Transport.DefaultResponseFactory.CreateCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, Exception ex, Nullable`1 statusCode, Dictionary`2 headers, Stream responseStream, String contentType, Int64 contentLength, IReadOnlyDictionary`2 threadPoolStats, IReadOnlyDictionary`2 tcpStats, CancellationToken cancellationToken)
at Elastic.Transport.HttpRequestInvoker.RequestCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, CancellationToken cancellationToken)
at Elastic.Transport.RequestPipeline.CallProductEndpointCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, Auditor auditor, CancellationToken cancellationToken)
at Elastic.Transport.DistributedTransport`1.RequestCoreAsync[TResponse](Boolean isAsync, EndpointPath path, PostData data, Action`1 configureActivity, IRequestConfiguration localConfiguration, CancellationToken cancellationToken)
# Inner Exception: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse`1[System.Object]. Path: $ | LineNumber: 0 | BytePositionInLine: 5295.
System.Text.Json.JsonException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse`1[System.Object]. Path: $ | LineNumber: 0 | BytePositionInLine: 5295.
---> System.FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int64.
at System.Text.Json.ThrowHelper.ThrowFormatException(NumericType numericType)
at System.Text.Json.Utf8JsonReader.GetInt64()
at Elastic.Clients.Elasticsearch.Serialization.StringifiedLongConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\StringifiedConverters.cs:line 81
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__12`2.<ReadUnionValue>b__12_1(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 406
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.ReadUnionValue[T1,T2](Utf8JsonReader& reader, JsonSerializerOptions options, JsonUnionSelectorFunc selector, JsonReadFunc`1 readType1, JsonReadFunc`1 readType2) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 406
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.<>c.<Read>b__0_3(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.ReadDictionaryValue[TKey,TValue](Utf8JsonReader& reader, JsonSerializerOptions options, JsonReadFunc`1 readKey, JsonReadFunc`1 readValue) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 325
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.<>c.<Read>b__0_1(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__16`1.<TryReadProperty>b__16_0(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 502
at Elastic.Clients.Elasticsearch.Aggregations.TDigestPercentilesAggregateConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\TDigestPercentilesAggregate.g.cs:line 43
at Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(Utf8JsonReader& reader, JsonSerializerOptions options, String& name, IAggregate& value) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\AggregateDictionary.g.cs:line 126
at Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\AggregateDictionary.g.cs:line 34
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__16`1.<TryReadProperty>b__16_0(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 502
at Elastic.Clients.Elasticsearch.SearchResponseConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Api\SearchResponse.g.cs:line 62
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, T& value, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, T& value)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
at Elastic.Transport.Products.Elasticsearch.ElasticsearchResponseBuilder.SetBodyCoreAsync[TResponse](Boolean isAsync, ApiCallDetails details, BoundConfiguration boundConfiguration, Stream responseStream, CancellationToken cancellationToken)
at Elastic.Transport.DefaultResponseFactory.CreateCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, Exception ex, Nullable`1 statusCode, Dictionary`2 headers, Stream responseStream, String contentType, Int64 contentLength, IReadOnlyDictionary`2 threadPoolStats, IReadOnlyDictionary`2 tcpStats, CancellationToken cancellationToken)
at Elastic.Transport.HttpRequestInvoker.RequestCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, CancellationToken cancellationToken)
at Elastic.Transport.RequestPipeline.CallProductEndpointCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, Auditor auditor, CancellationToken cancellationToken)
at Elastic.Transport.DistributedTransport`1.RequestCoreAsync[TResponse](Boolean isAsync, EndpointPath path, PostData data, Action`1 configureActivity, IRequestConfiguration localConfiguration, CancellationToken cancellationToken)
# Exception:
Elastic.Transport.UnexpectedTransportException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse`1[System.Object]. Path: $ | LineNumber: 0 | BytePositionInLine: 5295.
---> System.Text.Json.JsonException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse`1[System.Object]. Path: $ | LineNumber: 0 | BytePositionInLine: 5295.
---> System.FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int64.
at System.Text.Json.ThrowHelper.ThrowFormatException(NumericType numericType)
at System.Text.Json.Utf8JsonReader.GetInt64()
at Elastic.Clients.Elasticsearch.Serialization.StringifiedLongConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\StringifiedConverters.cs:line 81
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__12`2.<ReadUnionValue>b__12_1(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 406
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.ReadUnionValue[T1,T2](Utf8JsonReader& reader, JsonSerializerOptions options, JsonUnionSelectorFunc selector, JsonReadFunc`1 readType1, JsonReadFunc`1 readType2) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 406
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.<>c.<Read>b__0_3(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.ReadDictionaryValue[TKey,TValue](Utf8JsonReader& reader, JsonSerializerOptions options, JsonReadFunc`1 readKey, JsonReadFunc`1 readValue) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 325
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.<>c.<Read>b__0_1(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Aggregations.PercentilesConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\Percentiles.g.cs:line 33
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__16`1.<TryReadProperty>b__16_0(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 502
at Elastic.Clients.Elasticsearch.Aggregations.TDigestPercentilesAggregateConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\TDigestPercentilesAggregate.g.cs:line 43
at Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.ReadItem(Utf8JsonReader& reader, JsonSerializerOptions options, String& name, IAggregate& value) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\AggregateDictionary.g.cs:line 126
at Elastic.Clients.Elasticsearch.Aggregations.AggregateDictionaryConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Types\Aggregations\AggregateDictionary.g.cs:line 34
at Elastic.Clients.Elasticsearch.Serialization.JsonReaderExtensions.<>c__16`1.<TryReadProperty>b__16_0(Utf8JsonReader& r, JsonSerializerOptions o) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Shared\Next\JsonReaderExtensions.cs:line 502
at Elastic.Clients.Elasticsearch.SearchResponseConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\dev\shaneqld\elasticsearch-net\src\Elastic.Clients.Elasticsearch\_Generated\Api\SearchResponse.g.cs:line 62
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, T& value, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.ContinueDeserialize(ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, T& value)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsync(Stream utf8Json, CancellationToken cancellationToken)
at Elastic.Transport.Products.Elasticsearch.ElasticsearchResponseBuilder.SetBodyCoreAsync[TResponse](Boolean isAsync, ApiCallDetails details, BoundConfiguration boundConfiguration, Stream responseStream, CancellationToken cancellationToken)
at Elastic.Transport.DefaultResponseFactory.CreateCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, Exception ex, Nullable`1 statusCode, Dictionary`2 headers, Stream responseStream, String contentType, Int64 contentLength, IReadOnlyDictionary`2 threadPoolStats, IReadOnlyDictionary`2 tcpStats, CancellationToken cancellationToken)
at Elastic.Transport.HttpRequestInvoker.RequestCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, CancellationToken cancellationToken)
at Elastic.Transport.RequestPipeline.CallProductEndpointCoreAsync[TResponse](Boolean isAsync, Endpoint endpoint, BoundConfiguration boundConfiguration, PostData postData, Auditor auditor, CancellationToken cancellationToken)
at Elastic.Transport.DistributedTransport`1.RequestCoreAsync[TResponse](Boolean isAsync, EndpointPath path, PostData data, Action`1 configureActivity, IRequestConfiguration localConfiguration, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Elastic.Transport.DistributedTransport`1.ThrowUnexpectedTransportException[TResponse](Exception killerException, List`1 seenExceptions, Endpoint endpoint, TResponse response, IReadOnlyCollection`1 auditTrail)
at Elastic.Transport.DistributedTransport`1.RequestCoreAsync[TResponse](Boolean isAsync, EndpointPath path, PostData data, Action`1 configureActivity, IRequestConfiguration localConfiguration, CancellationToken cancellationToken)
Hi @shaneqld , thanks for reporting.
I'll check! The Percentiles type will most likely get a custom / handcrafted implementation since usability of the nested unions is not very great anyways.
I am seeing the exact same issue in 8.19.0, and it's a showstopper for us upgrading from 8.18 to 8.19.
We use PercentilesAggregation quite a lot in our code, and there is no trivial workaround to this.
Please consider prioritizing this.
Hi @jmisaxobank , I was on leave for quite a while and didn't have time to work on this issue yet.
It's on my list and not forgotten ๐
8.19.x essentially shares the core codebase with the 9.x clients which means it's not surprising that the issue exists in both versions.
@jmisaxobank Could you please send me the JSON response of one of the failing operations? I could use that as a reproducer, which would speed up validation of my proposed fix.
Sure, here is the JSON response from one of my failing tests.
The exception message I got looked like this:
Elastic.Transport.UnexpectedTransportException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse1[Iit.ClientExperiencePortal.Lib.DAL.Elastic.IngressNginx.Schema.NginxDoc]. Path: $ | LineNumber: 0 | BytePositionInLine: 371. ---> System.Text.Json.JsonException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse1[Iit.ClientExperiencePortal.Lib.DAL.Elastic.IngressNginx.Schema.NginxDoc]. Path: $ | LineNumber: 0 | BytePositionInLine: 371. ---> System.FormatException: Either the JSON value is not in a supported format, or is out of bounds for an Int64.
Thanks for looking into this matter.
Thank you @jmisaxobank .
The root cause of the problem seems to be an incorrect type in the specification. I created this PR to solve the issue.
Usability of this type is still not great, but this should at least unblock you until I got to improve the Percentiles type in general.
Thanks, yes the whole Union of Unions structure behind Elastic.Clients.Elasticsearch.Aggregations.Percentiles is a bit cumbersome to work with, but at least it's possible to code a small utility function around it. The parsing error however is not so easily bypassed.
@jmisaxobank Fixed in 8.19.1 / 9.1.1. I as well eliminated the union for better usability.
Between 8.19.0 and 8.19.1, the key in the list has changed from a string to a number. I don't quite understand why, as I have changed nothing in my test code.
8.19.0:
{"values":{"90.0":null}}
{"values":{"90.0":0.0058000000000000005}}
8.19.1 / 8.19.2:
{"values":[{"key":90.0,"value":null}]}
{"values":[{"key":90.0,"value":0.0058000000000000005}]}
So the test code still fails, now with an exception like this:
Elastic.Transport.UnexpectedTransportException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse1[Iit.ClientExperiencePortal.Lib.DAL.Elastic.IngressNginx.Schema.NginxDoc]. Path: $ | LineNumber: 0 | BytePositionInLine: 370. ---> System.Text.Json.JsonException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.SearchResponse1[Iit.ClientExperiencePortal.Lib.DAL.Elastic.IngressNginx.Schema.NginxDoc]. Path: $ | LineNumber: 0 | BytePositionInLine: 370. ---> System.InvalidOperationException: Cannot get the value of a token type 'Number' as a string.
@jmisaxobank That's unexpected. I'll check again tomorrow.
@jmisaxobank There was another type problem in the Elasticsearch specification. I created a PR and will release a new version of the client shortly after it gets merged ๐
Should finally be fixed now in 8.19.3 / 9.1.4.
8.19.3 passes my automated tests as well, so it looks promising. ๐
Thanks for the quick help.