From e13eb4982e36aa728f077eca38496b34db1782c9 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Fri, 28 Jul 2023 17:19:06 +0100 Subject: [PATCH] Fix feature not available exception --- core/impl/lookup_in_all_replicas.cxx | 4 ++++ core/impl/lookup_in_any_replica.cxx | 3 +++ core/impl/lookup_in_replica.cxx | 5 +---- core/operations/document_lookup_in_all_replicas.hxx | 4 ++++ core/operations/document_lookup_in_any_replica.hxx | 4 ++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/impl/lookup_in_all_replicas.cxx b/core/impl/lookup_in_all_replicas.cxx index b203038d0..ddb13238e 100644 --- a/core/impl/lookup_in_all_replicas.cxx +++ b/core/impl/lookup_in_all_replicas.cxx @@ -61,6 +61,10 @@ initiate_lookup_in_all_replicas_operation(std::shared_ptr core, core->with_bucket_configuration( bucket_name, [core, r = std::move(request), h = std::move(handler)](std::error_code ec, const core::topology::configuration& config) mutable { + if (!config.supports_subdoc_read_replica()) { + ec = errc::common::feature_not_available; + } + if (ec) { std::optional first_error_path{}; std::optional first_error_index{}; diff --git a/core/impl/lookup_in_any_replica.cxx b/core/impl/lookup_in_any_replica.cxx index 889bae5ae..49f96df25 100644 --- a/core/impl/lookup_in_any_replica.cxx +++ b/core/impl/lookup_in_any_replica.cxx @@ -60,6 +60,9 @@ initiate_lookup_in_any_replica_operation(std::shared_ptr core, core->with_bucket_configuration( bucket_name, [core, r = std::move(request), h = std::move(handler)](std::error_code ec, const core::topology::configuration& config) mutable { + if (!config.supports_subdoc_read_replica()) { + ec = errc::common::feature_not_available; + } if (ec) { std::optional first_error_path{}; std::optional first_error_index{}; diff --git a/core/impl/lookup_in_replica.cxx b/core/impl/lookup_in_replica.cxx index 6375d3dda..ace8347dc 100644 --- a/core/impl/lookup_in_replica.cxx +++ b/core/impl/lookup_in_replica.cxx @@ -23,11 +23,8 @@ namespace couchbase::core::impl { std::error_code -lookup_in_replica_request::encode_to(lookup_in_replica_request::encoded_request_type& encoded, mcbp_context&& context) +lookup_in_replica_request::encode_to(lookup_in_replica_request::encoded_request_type& encoded, mcbp_context&& /* context */) { - if (!context.config->supports_subdoc_read_replica()) { - return errc::common::feature_not_available; - } for (std::size_t i = 0; i < specs.size(); ++i) { specs[i].original_index_ = i; } diff --git a/core/operations/document_lookup_in_all_replicas.hxx b/core/operations/document_lookup_in_all_replicas.hxx index 2f2b941d7..39316ba8b 100644 --- a/core/operations/document_lookup_in_all_replicas.hxx +++ b/core/operations/document_lookup_in_all_replicas.hxx @@ -73,6 +73,10 @@ struct lookup_in_all_replicas_request { id.bucket(), [core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward(handler)]( std::error_code ec, const topology::configuration& config) mutable { + if (!config.supports_subdoc_read_replica()) { + ec = errc::common::feature_not_available; + } + if (ec) { std::optional first_error_path{}; std::optional first_error_index{}; diff --git a/core/operations/document_lookup_in_any_replica.hxx b/core/operations/document_lookup_in_any_replica.hxx index 67dfcb04f..3dda19da7 100644 --- a/core/operations/document_lookup_in_any_replica.hxx +++ b/core/operations/document_lookup_in_any_replica.hxx @@ -57,6 +57,10 @@ struct lookup_in_any_replica_request { id.bucket(), [core, id = id, timeout = timeout, specs = specs, parent_span = parent_span, h = std::forward(handler)]( std::error_code ec, const topology::configuration& config) mutable { + if (!config.supports_subdoc_read_replica()) { + ec = errc::common::feature_not_available; + } + if (ec) { std::optional first_error_path{}; std::optional first_error_index{};