@@ -1323,6 +1323,43 @@ def search_request(condition_size: int = 2):
13231323 assert not search_fail .ok
13241324
13251325
1326+ def test_strict_mode_formula_expression (collection_name ):
1327+ set_strict_mode (collection_name , {
1328+ "enabled" : True ,
1329+ "condition_max_size" : 1000000 , # Disabled
1330+ "unindexed_filtering_retrieve" : False ,
1331+ })
1332+
1333+ def query_request ():
1334+ expression = {
1335+ "sum" : [
1336+ "discount_price" ,
1337+ "$score" ,
1338+ ]
1339+ }
1340+
1341+ return request_with_validation (
1342+ api = '/collections/{collection_name}/points/query' ,
1343+ method = "POST" ,
1344+ path_params = {'collection_name' : collection_name },
1345+ body = {
1346+ "prefetch" : {
1347+ "query" : [0.1 , 0.2 , 0.3 , 0.4 ],
1348+ },
1349+ "query" : {
1350+ "formula" : expression ,
1351+ "defaults" : { "discount_price" : 0 } # Even with default, it should still be restricted
1352+ }
1353+ }
1354+ )
1355+
1356+ query_fail = query_request ()
1357+ print (query_fail .json ())
1358+ assert not query_fail .ok
1359+ assert "discount_price" in query_fail .json ()['status' ]['error' ]
1360+ assert "formula expression" in query_fail .json ()['status' ]['error' ]
1361+
1362+
13261363def test_strict_mode_read_rate_limiting_small_replenish (collection_name ):
13271364 """
13281365 If our read rate limit capacity is larger, test that when exhausting it
@@ -1418,4 +1455,4 @@ def test_strict_mode_unset_rate_limiting_config(collection_name):
14181455 assert new_strict_mode_config ['enabled' ]
14191456 assert new_strict_mode_config ['read_rate_limit' ] == 2
14201457 # assert write rate limit is not unset because it is currently not supported
1421- assert new_strict_mode_config ['write_rate_limit' ] == 1
1458+ assert new_strict_mode_config ['write_rate_limit' ] == 1
0 commit comments