diff --git a/integration/test_query_parser.py b/integration/test_query_parser.py index 65844b40f..a9dfef9f8 100644 --- a/integration/test_query_parser.py +++ b/integration/test_query_parser.py @@ -36,7 +36,7 @@ def test_query_string_depth_limit(self): """ client: Valkey = self.server.get_new_client() # Test that the default query string limit is 1000 - assert client.execute_command("CONFIG GET search.query-string-depth") == [b"search.query-string-depth", b"1000"] + assert client.execute_command("CONFIG GET search.query-string-depth") == [b"search.query-string-depth", b"16"] # Test that we can set the query string limit to 1 assert client.execute_command("CONFIG SET search.query-string-depth 1") == b"OK" assert client.execute_command("FT.CREATE my_index ON HASH PREFIX 1 doc: SCHEMA price NUMERIC category TAG SEPARATOR | doc_embedding VECTOR FLAT 6 TYPE FLOAT32 DIM 128 DISTANCE_METRIC COSINE") == b"OK" @@ -83,17 +83,17 @@ def test_query_string_depth_limit(self): assert False except ResponseError as e: assert str(e) == "Invalid filter expression: `((((((((((@price:[10 20]))))))))))`. Query string is too complex" - # Test that the config ranges from 1 to 4294967295 + # Test that the config ranges from 1 to 16 try: client.execute_command("CONFIG SET search.query-string-depth 0") assert False except ResponseError as e: - assert "argument must be between 1 and 4294967295 inclusive" in str(e) + assert "argument must be between 1 and 16 inclusive" in str(e) try: - client.execute_command("CONFIG SET search.query-string-depth 4294967296") + client.execute_command("CONFIG SET search.query-string-depth 17") assert False except ResponseError as e: - assert "argument must be between 1 and 4294967295 inclusive" in str(e) + assert "argument must be between 1 and 16 inclusive" in str(e) def test_query_string_terms_count_limit(self): """ diff --git a/src/commands/filter_parser.cc b/src/commands/filter_parser.cc index ff2135a51..de47e6ca1 100644 --- a/src/commands/filter_parser.cc +++ b/src/commands/filter_parser.cc @@ -36,14 +36,14 @@ namespace options { /// Register the "--query-string-depth" flag. Controls the depth of the query /// string parsing from the FT.SEARCH cmd. constexpr absl::string_view kQueryStringDepthConfig{"query-string-depth"}; -constexpr uint32_t kDefaultQueryStringDepth{1000}; +constexpr uint32_t kMaxQueryStringDepth{16}; constexpr uint32_t kMinimumQueryStringDepth{1}; static auto query_string_depth = config::NumberBuilder(kQueryStringDepthConfig, // name - kDefaultQueryStringDepth, // default size + kMaxQueryStringDepth, // default size kMinimumQueryStringDepth, // min size - UINT_MAX) // max size - .WithValidationCallback(CHECK_RANGE(kMinimumQueryStringDepth, UINT_MAX, + kMaxQueryStringDepth) // max size + .WithValidationCallback(CHECK_RANGE(kMinimumQueryStringDepth, kMaxQueryStringDepth, kQueryStringDepthConfig)) .Build(); diff --git a/src/commands/ft_create_parser.cc b/src/commands/ft_create_parser.cc index 45cd4a52a..a7ac30712 100644 --- a/src/commands/ft_create_parser.cc +++ b/src/commands/ft_create_parser.cc @@ -63,7 +63,7 @@ constexpr int kDefaultTagFieldLenLimit{256}; constexpr int kDefaultNumericFieldLenLimit{128}; constexpr size_t kMaxAttributesCount{100}; constexpr int kMaxDimensionsCount{64000}; -constexpr int kMaxM{2000000}; +constexpr int kMaxM{256}; constexpr int kMaxEfConstruction{4096}; constexpr int kMaxEfRuntime{4096}; constexpr int kMaxPrefixesCount{16}; diff --git a/src/valkey_search_options.cc b/src/valkey_search_options.cc index 3592876b9..c99d747f0 100644 --- a/src/valkey_search_options.cc +++ b/src/valkey_search_options.cc @@ -55,13 +55,16 @@ namespace config = vmsdk::config; /// Register the "--query-string-bytes" flag. Controls the length of the query /// string of the FT.SEARCH cmd. constexpr absl::string_view kQueryStringBytesConfig{"query-string-bytes"}; -constexpr uint32_t kDefaultQueryStringBytes{10240}; +constexpr uint32_t kMaxQueryStringBytes{10240}; constexpr uint32_t kMinimumQueryStringBytes{1}; static auto query_string_bytes = config::NumberBuilder(kQueryStringBytesConfig, // name - kDefaultQueryStringBytes, // default size + kMaxQueryStringBytes, // default size kMinimumQueryStringBytes, // min size - UINT_MAX) // max size + kMaxQueryStringBytes) // max size + .WithValidationCallback(CHECK_RANGE(kMinimumQueryStringBytes, + kMaxQueryStringBytes, + kQueryStringBytesConfig)) .Build(); constexpr absl::string_view kHNSWBlockSizeConfig{"hnsw-block-size"}; diff --git a/testing/ft_create_parser_test.cc b/testing/ft_create_parser_test.cc index c00a167cc..f3a526998 100644 --- a/testing/ft_create_parser_test.cc +++ b/testing/ft_create_parser_test.cc @@ -653,7 +653,7 @@ INSTANTIATE_TEST_SUITE_P( .expected_error_message = "Invalid field type for field `hash_field1`: Invalid range: " "Value below minimum; M must be a positive integer greater " - "than 0 and cannot exceed 2000000.", + "than 0 and cannot exceed 256.", }, { .test_name = "invalid_m_too_big", @@ -664,7 +664,7 @@ INSTANTIATE_TEST_SUITE_P( .expected_error_message = "Invalid field type for field `hash_field1`: Invalid range: " "Value above maximum; M must be a positive integer greater " - "than 0 and cannot exceed 2000000.", + "than 0 and cannot exceed 256.", }, { .test_name = "invalid_ef_construction_zero",