Description
Elastic.Clients.Elasticsearch version: 8.0.5
Elasticsearch version: 8.6.0
.NET runtime version: 6
Operating system version: macOS Monetery : 12.6.3
Description of the problem including expected versus actual behavior:
After a CreateDataStreamAsync
and the process has finished, I re-spin up the process and it executes GetDataStreamAsync
which then throws this exception
The JSON value could not be converted to Elastic.Clients.Elasticsearch.HealthStatus. Path: $.data_streams[0].status | LineNumber: 18 | BytePositionInLine: 24.
of type: UnexpectedTransportException
Steps to reproduce:
module EsDataStream =
let dataStreamExists (getClient: unit -> ElasticsearchClient) (logIndex: string) (cancellationToken: CancellationToken) = task {
let client = getClient ()
let dsRequest = GetDataStreamRequest(logIndex)
let! exists = client.Indices.GetDataStreamAsync(dsRequest, cancellationToken)
return if not exists.IsValidResponse || exists.DataStreams.Count <> 0 then false
else exists.DataStreams.Count = 1 // = is equiv to ==
}
let dataStreamCreate (getClient: unit -> ElasticsearchClient) (logIndex: string) (cancellationToken: CancellationToken) = task {
let client = getClient ()
let request = CreateDataStreamRequest(logIndex)
let! response = client.Indices.CreateDataStreamAsync(request, cancellationToken)
return response.IsValidResponse && response.Acknowledged
}
These are used like so:
let! result =
EsDataStream.dataStreamExists getClient logIndex cancellationToken
|> Task.bind (fun result ->
if not result then EsDataStream.dataStreamCreate getClient logIndex cancellationToken
else Task.FromResult(true))
return result
All that function basically does, is if the result from dataStreamExists
is false
, then it will fire off dataStreamCreate
.
The exception gets thrown from the GetDataStreamAsync
Elastic.Transport.UnexpectedTransportException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.HealthStatus. Path: $.data_streams[0].status | LineNumber: 18 | BytePositionInLine: 24.
---> System.Text.Json.JsonException: The JSON value could not be converted to Elastic.Clients.Elasticsearch.HealthStatus. Path: $.data_streams[0].status | LineNumber: 18 | BytePositionInLine: 24.
at Elastic.Clients.Elasticsearch.ThrowHelper.ThrowJsonException(String message) in //src/Elastic.Clients.Elasticsearch/Core/Exceptions/ThrowHelper.cs:line 14
at Elastic.Clients.Elasticsearch.HealthStatusConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in //src/Elastic.Clients.Elasticsearch/Generated/Types/Enums/Enums.NoNamespace.g.cs:line 480
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.Metadata.JsonPropertyInfo
1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
at System.Text.Json.Serialization.Converters.ObjectDefaultConverter1.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)
at System.Text.Json.Serialization.JsonCollectionConverter2.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, TCollection& value) at System.Text.Json.Serialization.JsonConverter
1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.Metadata.JsonPropertyInfo1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader) at System.Text.Json.Serialization.Converters.ObjectDefaultConverter
1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
at System.Text.Json.Serialization.JsonConverter1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value) at System.Text.Json.Serialization.JsonConverter
1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonConverter jsonConverter, Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadCore[TValue](JsonReaderState& readerState, Boolean isFinalBlock, ReadOnlySpan1 buffer, JsonSerializerOptions options, ReadStack& state, JsonConverter converterBase) at System.Text.Json.JsonSerializer.ContinueDeserialize[TValue](ReadBufferState& bufferState, JsonReaderState& jsonReaderState, ReadStack& readStack, JsonConverter converter, JsonSerializerOptions options) at System.Text.Json.JsonSerializer.ReadAllAsync[TValue](Stream utf8Json, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) at Elastic.Transport.DefaultResponseBuilder
1.SetBodyAsync[TResponse](ApiCallDetails details, RequestData requestData, Stream responseStream, String mimeType, CancellationToken cancellationToken)
at Elastic.Transport.DefaultResponseBuilder1.ToResponseAsync[TResponse](RequestData requestData, Exception ex, Nullable
1 statusCode, Dictionary2 headers, Stream responseStream, String mimeType, Int64 contentLength, IReadOnlyDictionary
2 threadPoolStats, IReadOnlyDictionary2 tcpStats, CancellationToken cancellationToken) at Elastic.Transport.HttpTransportClient.RequestAsync[TResponse](RequestData requestData, CancellationToken cancellationToken) at Elastic.Transport.DefaultRequestPipeline
1.CallProductEndpointAsync[TResponse](RequestData requestData, CancellationToken cancellationToken)
at Elastic.Transport.DefaultHttpTransport1.RequestAsync[TResponse](HttpMethod method, String path, PostData data, RequestParameters requestParameters, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Elastic.Transport.DefaultHttpTransport
1.RequestAsync[TResponse](HttpMethod method, String path, PostData data, RequestParameters requestParameters, CancellationToken cancellationToken)
at Elastic.Clients.Elasticsearch.ElasticsearchClient.<>c__DisplayClass32_0`3.<g__SendRequest|0>d.MoveNext() in //src/Elastic.Clients.Elasticsearch/Client/ElasticsearchClient.cs:line 374
--- End of stack trace from previous location ---
at EsLogging.EsDataStream.dataStreamExists@36.MoveNext()
Expected behavior
What should happen is the response gets serialised properly