From 4246457dcd215246ebd8c43c901aa92061b85a4e Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Mon, 27 Apr 2026 15:05:34 +0200 Subject: [PATCH 1/2] Remove ElasticsearchClientProductRegistration overrides MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both overrides on `ElasticsearchClientProductRegistration` are obsoleted by the centralised error-extraction work in `Elastic.Transport` (PR elastic/elastic-transport-net#205) and the throw alignment in elastic/elastic-transport-net#208: - `HttpStatusCodeClassifier` had an `or 404` clause to keep the low-level transport from throwing on legitimate 404s under `ThrowExceptions=true`. Post-#205 the same predicate gates `mayHaveErrorBody` in `DefaultResponseFactory`, so the override silently disabled product error extraction for every 404 — leaving `ProductError` null, `IsValidResponse` lenient, and the typed builder blowing up with `UnexpectedTransportException` on bodies that don't match the typed response shape (missing alias / missing index get). The throw concern is now addressed product-side via `ProductRegistration.IsValidResponse`, which the new transport throw path consults; keeping the override here would re-introduce the error-extraction regression. - `TryGetServerErrorReason` was a no-op duplicate post-#205. It cast to `ElasticsearchResponse` and read `r.ElasticsearchServerError?.Error`, but `ElasticsearchServerError` is a computed property over `ApiCallDetails.ProductError`, which is exactly what the base implementation in `ElasticsearchProductRegistration` already reads. Class is now constructor + `DefaultForElasticsearchClientsElasticsearch` factory only. Fixes elastic/elastic-transport-net#206. The `Elastic.Transport` PackageReference bump that ships the throw-alignment change will follow as a separate commit once that PR is released. --- .../ElasticsearchClientProductRegistration.cs | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/src/Elastic.Clients.Elasticsearch/Core/ElasticsearchClientProductRegistration.cs b/src/Elastic.Clients.Elasticsearch/Core/ElasticsearchClientProductRegistration.cs index 6c5e75b814e..725779fd326 100644 --- a/src/Elastic.Clients.Elasticsearch/Core/ElasticsearchClientProductRegistration.cs +++ b/src/Elastic.Clients.Elasticsearch/Core/ElasticsearchClientProductRegistration.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Diagnostics.CodeAnalysis; -using Elastic.Transport; using Elastic.Transport.Products.Elasticsearch; namespace Elastic.Clients.Elasticsearch; @@ -14,26 +12,4 @@ internal sealed class ElasticsearchClientProductRegistration : ElasticsearchProd public ElasticsearchClientProductRegistration(Type markerType) : base(markerType) { } public static ElasticsearchClientProductRegistration DefaultForElasticsearchClientsElasticsearch { get; } = new(typeof(ElasticsearchClient)); - - /// - /// Elastic.Clients.Elasticsearch handles 404 in its , we do not want the low level client throwing - /// exceptions - /// when is enabled for 404's. The client is in charge of - /// composing paths - /// so a 404 never signals a wrong URL but a missing entity. - /// - public override bool HttpStatusCodeClassifier(HttpMethod method, int statusCode) => - statusCode is >= 200 and < 300 or 404; - - /// - /// Makes the low level transport aware of Elastic.Clients.Elasticsearch's - /// so that it can peek in to its exposed error when reporting failures. - /// - public override bool TryGetServerErrorReason(TResponse response, [NotNullWhen(returnValue: true)] out string? reason) - { - if (response is not ElasticsearchResponse r) - return base.TryGetServerErrorReason(response, out reason); - reason = r.ElasticsearchServerError?.Error?.ToString(); - return !string.IsNullOrEmpty(reason); - } } From 4e99bcad61b3690177d377a076aa5a2995f726ea Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Tue, 28 Apr 2026 10:54:21 +0200 Subject: [PATCH 2/2] Bump Elastic.Transport to 0.17.0 --- .../Elastic.Clients.Elasticsearch.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj index aeab1d403da..9cf454fe07e 100644 --- a/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj +++ b/src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj @@ -32,7 +32,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive