Skip to content

Commit 2237fb0

Browse files
committed
Adjust operational limits
Signed-off-by: Arad Zilberstein <[email protected]>
1 parent 54ffb1b commit 2237fb0

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

integration/test_query_parser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def test_query_string_depth_limit(self):
3636
"""
3737
client: Valkey = self.server.get_new_client()
3838
# Test that the default query string limit is 1000
39-
assert client.execute_command("CONFIG GET search.query-string-depth") == [b"search.query-string-depth", b"1000"]
39+
assert client.execute_command("CONFIG GET search.query-string-depth") == [b"search.query-string-depth", b"16"]
4040
# Test that we can set the query string limit to 1
4141
assert client.execute_command("CONFIG SET search.query-string-depth 1") == b"OK"
4242
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):
8383
assert False
8484
except ResponseError as e:
8585
assert str(e) == "Invalid filter expression: `((((((((((@price:[10 20]))))))))))`. Query string is too complex"
86-
# Test that the config ranges from 1 to 4294967295
86+
# Test that the config ranges from 1 to 16
8787
try:
8888
client.execute_command("CONFIG SET search.query-string-depth 0")
8989
assert False
9090
except ResponseError as e:
91-
assert "argument must be between 1 and 4294967295 inclusive" in str(e)
91+
assert "argument must be between 1 and 16 inclusive" in str(e)
9292
try:
93-
client.execute_command("CONFIG SET search.query-string-depth 4294967296")
93+
client.execute_command("CONFIG SET search.query-string-depth 17")
9494
assert False
9595
except ResponseError as e:
96-
assert "argument must be between 1 and 4294967295 inclusive" in str(e)
96+
assert "argument must be between 1 and 16 inclusive" in str(e)
9797

9898
def test_query_string_terms_count_limit(self):
9999
"""

src/commands/filter_parser.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ namespace options {
3636
/// Register the "--query-string-depth" flag. Controls the depth of the query
3737
/// string parsing from the FT.SEARCH cmd.
3838
constexpr absl::string_view kQueryStringDepthConfig{"query-string-depth"};
39-
constexpr uint32_t kDefaultQueryStringDepth{1000};
39+
constexpr uint32_t kMaxQueryStringDepth{16};
4040
constexpr uint32_t kMinimumQueryStringDepth{1};
4141
static auto query_string_depth =
4242
config::NumberBuilder(kQueryStringDepthConfig, // name
43-
kDefaultQueryStringDepth, // default size
43+
kMaxQueryStringDepth, // default size
4444
kMinimumQueryStringDepth, // min size
45-
UINT_MAX) // max size
46-
.WithValidationCallback(CHECK_RANGE(kMinimumQueryStringDepth, UINT_MAX,
45+
kMaxQueryStringDepth) // max size
46+
.WithValidationCallback(CHECK_RANGE(kMinimumQueryStringDepth, kMaxQueryStringDepth,
4747
kQueryStringDepthConfig))
4848
.Build();
4949

src/commands/ft_create_parser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ constexpr int kDefaultTagFieldLenLimit{256};
6363
constexpr int kDefaultNumericFieldLenLimit{128};
6464
constexpr size_t kMaxAttributesCount{100};
6565
constexpr int kMaxDimensionsCount{64000};
66-
constexpr int kMaxM{2000000};
66+
constexpr int kMaxM{256};
6767
constexpr int kMaxEfConstruction{4096};
6868
constexpr int kMaxEfRuntime{4096};
6969
constexpr int kMaxPrefixesCount{16};

src/valkey_search_options.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ namespace config = vmsdk::config;
5555
/// Register the "--query-string-bytes" flag. Controls the length of the query
5656
/// string of the FT.SEARCH cmd.
5757
constexpr absl::string_view kQueryStringBytesConfig{"query-string-bytes"};
58-
constexpr uint32_t kDefaultQueryStringBytes{10240};
58+
constexpr uint32_t kMaxQueryStringBytes{10240};
5959
constexpr uint32_t kMinimumQueryStringBytes{1};
6060
static auto query_string_bytes =
6161
config::NumberBuilder(kQueryStringBytesConfig, // name
62-
kDefaultQueryStringBytes, // default size
62+
kMaxQueryStringBytes, // default size
6363
kMinimumQueryStringBytes, // min size
64-
UINT_MAX) // max size
64+
kMaxQueryStringBytes) // max size
65+
.WithValidationCallback(CHECK_RANGE(kMinimumQueryStringBytes,
66+
kMaxQueryStringBytes,
67+
kQueryStringBytesConfig))
6568
.Build();
6669

6770
constexpr absl::string_view kHNSWBlockSizeConfig{"hnsw-block-size"};

testing/ft_create_parser_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ INSTANTIATE_TEST_SUITE_P(
653653
.expected_error_message =
654654
"Invalid field type for field `hash_field1`: Invalid range: "
655655
"Value below minimum; M must be a positive integer greater "
656-
"than 0 and cannot exceed 2000000.",
656+
"than 0 and cannot exceed 256.",
657657
},
658658
{
659659
.test_name = "invalid_m_too_big",
@@ -664,7 +664,7 @@ INSTANTIATE_TEST_SUITE_P(
664664
.expected_error_message =
665665
"Invalid field type for field `hash_field1`: Invalid range: "
666666
"Value above maximum; M must be a positive integer greater "
667-
"than 0 and cannot exceed 2000000.",
667+
"than 0 and cannot exceed 256.",
668668
},
669669
{
670670
.test_name = "invalid_ef_construction_zero",

0 commit comments

Comments
 (0)