-
Notifications
You must be signed in to change notification settings - Fork 1.2k
GetDataStreamAsync throws JSON value could not be converted to Elastic.Clients.Elasticsearch.HealthStatus #7236
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
Comments
The output from the DevTools is: Executing: {
"data_streams": [
{
"name": "logs-dev",
"timestamp_field": {
"name": "@timestamp"
},
"indices": [
{
"index_name": ".ds-logs-dev-2023.02.16-000001",
"index_uuid": "xyWXN5T1Rm6_sOCayv7GDA"
}
],
"generation": 1,
"_meta": {
"description": "default logs template installed by x-pack",
"managed": true
},
"status": "GREEN",
"template": "logs",
"ilm_policy": "logs",
"hidden": false,
"system": false,
"allow_custom_routing": false,
"replicated": false
}
]
} |
The auto gen'd code is: [JsonConverter(typeof(HealthStatusConverter))]
public enum HealthStatus
{
[EnumMember(Value = "yellow")]
Yellow,
[EnumMember(Value = "red")]
Red,
[EnumMember(Value = "green")]
Green
}
internal sealed class HealthStatusConverter : JsonConverter<HealthStatus>
{
public override HealthStatus Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var enumString = reader.GetString();
switch (enumString)
{
case "yellow":
return HealthStatus.Yellow;
case "red":
return HealthStatus.Red;
case "green":
return HealthStatus.Green;
}
ThrowHelper.ThrowJsonException();
return default;
}
public override void Write(Utf8JsonWriter writer, HealthStatus value, JsonSerializerOptions options)
{
switch (value)
{
case HealthStatus.Yellow:
writer.WriteStringValue("yellow");
return;
case HealthStatus.Red:
writer.WriteStringValue("red");
return;
case HealthStatus.Green:
writer.WriteStringValue("green");
return;
}
writer.WriteNullValue();
}
} |
The casing shouldn't be a problem... but the code doesn't seem to support |
Thanks for raising this, @no1melman, and for the comprehensive analysis. I'll discuss this with the team as this is not something we capture in the specification, which assumes that all uses of |
Also, @stevejgordon , I set |
When enabled, the request/response should appear in the |
We do handle this inconsistent casing for |
Yeah this doesn't do this for some reason - let me have a more of an investigation - this is obviously really useful for debugging this kind of thing, rather than going round the houses |
Ahh - maybe because of this JSON format exception - maybe you don't back track, and reserialise the stream as a string for the exception. psuedo
|
@no1melman, I see what you mean. Yes, if an exception is thrown this low down, we don't collect and attach the response body anywhere. That's something we can look at in the future if it's practical. |
It becomes quite the chore to debug if the JSON fails and we can't see what the original string response was to work out where in could have possibly failed |
I agree. In this case, this is an exception in deserialising our type, so it shouldn't be up to you to debug it. For source-related exceptions, this would be far more valid for debugging. I've captured this on our roadmap. |
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 executesGetDataStreamAsync
which then throws this exceptionof type:
UnexpectedTransportException
Steps to reproduce:
These are used like so:
All that function basically does, is if the result from
dataStreamExists
isfalse
, then it will fire offdataStreamCreate
.The exception gets thrown from the
GetDataStreamAsync
Expected behavior
What should happen is the response gets serialised properly
The text was updated successfully, but these errors were encountered: