Skip to content

Commit c6be14e

Browse files
authored
CXXCBC-365: handle >16 specs in lookup_in_any_replica (#441)
1 parent b6148c1 commit c6be14e

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

core/impl/lookup_in_any_replica.cxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ initiate_lookup_in_any_replica_operation(std::shared_ptr<cluster> core,
6363
if (!config.supports_subdoc_read_replica()) {
6464
ec = errc::common::feature_not_available;
6565
}
66+
if (r->specs().size() > 16) {
67+
ec = errc::common::invalid_argument;
68+
}
6669
if (ec) {
6770
std::optional<std::string> first_error_path{};
6871
std::optional<std::size_t> first_error_index{};

core/operations/document_lookup_in_any_replica.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ struct lookup_in_any_replica_request {
6969
if (!config.supports_subdoc_read_replica()) {
7070
ec = errc::common::feature_not_available;
7171
}
72+
if (specs.size() > 16) {
73+
ec = errc::common::invalid_argument;
74+
}
7275

7376
if (ec) {
7477
std::optional<std::string> first_error_path{};

test/test_integration_subdoc.cxx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,21 @@ TEST_CASE("integration: subdoc any replica reads", "[integration]")
14871487
couchbase::errc::key_value::path_mismatch);
14881488
}
14891489

1490+
SECTION("too many specs")
1491+
{
1492+
couchbase::core::operations::lookup_in_any_replica_request req{ id };
1493+
auto specs = couchbase::lookup_in_specs{};
1494+
1495+
for (int i = 0; i < 17; i++) {
1496+
specs.push_back(couchbase::lookup_in_specs::get("dictkey"));
1497+
}
1498+
req.specs = specs.specs();
1499+
1500+
auto resp = test::utils::execute(integration.cluster, req);
1501+
REQUIRE(resp.ctx.ec() == couchbase::errc::common::invalid_argument);
1502+
REQUIRE(resp.fields.empty());
1503+
}
1504+
14901505
SECTION("public API")
14911506
{
14921507
auto collection = couchbase::cluster(integration.cluster).bucket(integration.ctx.bucket).scope("_default").collection("_default");
@@ -1513,5 +1528,17 @@ TEST_CASE("integration: subdoc any replica reads", "[integration]")
15131528
REQUIRE(ctx.ec() == couchbase::errc::key_value::document_irretrievable);
15141529
REQUIRE(result.cas().empty());
15151530
}
1531+
1532+
SECTION("too many specs")
1533+
{
1534+
auto specs = couchbase::lookup_in_specs{};
1535+
1536+
for (int i = 0; i < 17; i++) {
1537+
specs.push_back(couchbase::lookup_in_specs::get("dictkey"));
1538+
}
1539+
auto [ctx, result] = collection.lookup_in_any_replica(key, specs).get();
1540+
REQUIRE(ctx.ec() == couchbase::errc::common::invalid_argument);
1541+
REQUIRE(result.cas().empty());
1542+
}
15161543
}
15171544
}

0 commit comments

Comments
 (0)