-
Notifications
You must be signed in to change notification settings - Fork 197
fix: Don't set include_type_name query param for ES v7 template creation call #519
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is the the actual issue, because condition somehow got reversed from <
to >=
during refactoring for final 9.0.0
:
Line 55 in a01baff
private bool IncludeTypeName => _versionManager.EffectiveVersion.Major >= 7; |
Could be fixed something like this (+ removing private member above completely):
StringResponse result;
if (_versionManager.EffectiveVersion.Major < 8)
{
result = _client.Indices.PutTemplateForAll<StringResponse>(_templateName, GetTemplatePostData(),
new PutIndexTemplateRequestParameters
{
IncludeTypeName = _versionManager.EffectiveVersion.Major < 7 ? true : null
});
}
else
{
// Default to version 8 API
result = _client.Indices.PutTemplateV2ForAll<StringResponse>(_templateName, GetTemplatePostData());
}
Or, if you prefer switch
expression, please make it a bit simpler, so it's easier to read:
var result = _versionManager.EffectiveVersion.Major switch
{
< 8 => _client.Indices.PutTemplateForAll<StringResponse>(_templateName, GetTemplatePostData(),
new PutIndexTemplateRequestParameters
{
IncludeTypeName = _versionManager.EffectiveVersion.Major < 7 ? true : null
}),
// Default to version 8 API
_ => _client.Indices.PutTemplateV2ForAll<StringResponse>(_templateName, GetTemplatePostData()),
};
It would also be great if you can add this check to unit tests after check for Path:
Line 45 in a01baff
uri.AbsolutePath.Should().Be("/_template/serilog-events-template"); |
And in v7 and v8 to ensure that uri.Query
should not contain include_type_name
parameter.
Any updates on this PR? |
@RefaelP23 Yes, this was coding error. @AlexGoris-KasparSolutions did not yet reply to my review suggestions. |
@nenadvicentic Thanks for the prompt reply. I also saw your discussion here Added original exception to FailureCallback action and I understand that it might take some time until it's released. |
@RefaelP23 From the top of my head, I can only think of this two options:
|
@nenadvicentic this one can be removed/closed now? |
What issue does this PR address?
#518
Does this PR introduce a breaking change?
No
Please check if the PR fulfils these requirements
Sorry, there are no unit tests around the changed code, and making them would require me to mock the
ElasticLowLevelClient
that's being used there, which would require more time then I can spend on this.Other information:
The previous code (treat all <8 version the same) would have been fine if the
TypeName
would have had a valid value, but I noticed that in the constructor of theElasticsearchSinkState
class we have some code which sets its value tonull
for anything higher or equal to ES v7:Therefor you had a scenario for ES v7 where the
TypeName
would benull
, but theinclude_type_name
query parameter would be set totrue
, which wasn't a valid API call for ES v7