Skip to content

Commit bf7966f

Browse files
Reduce nesting depth in tests to respect server CQL limit
Scylla now limits CQL expression nesting depth to 12 (CVE-2026-31948, scylladb commit e35c388), rejecting deeper literals with the error "expression nested too deeply". The limit counts every recursive `term`, including the innermost scalar value: - nested tuple literals max out at 11 levels deep - nested UDT literals max out at 10 levels deep (a UDT literal {value: ...} adds two term levels per nesting) Adjust test_can_insert_nested_tuples to depth 11 and the nested UDT tests to depth 10.
1 parent 28ddc07 commit bf7966f

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

tests/integration/standard/test_types.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,20 +663,22 @@ def test_can_insert_nested_tuples(self):
663663
s.encoder.mapping[tuple] = s.encoder.cql_encode_tuple
664664

665665
# create a table with multiple sizes of nested tuples
666-
# Note: Scylla limits CQL expression nesting depth to 12, so the
667-
# deepest tuple tested here is 12 levels deep.
666+
# Note: Scylla limits CQL expression nesting depth to 12 (every
667+
# recursive `term` counts, including the innermost scalar value), so a
668+
# nested tuple literal can be at most 11 levels deep before the server
669+
# rejects it with "expression nested too deeply".
668670
s.execute("CREATE TABLE nested_tuples ("
669671
"k int PRIMARY KEY, "
670672
"v_1 frozen<%s>,"
671673
"v_2 frozen<%s>,"
672674
"v_3 frozen<%s>,"
673-
"v_12 frozen<%s>"
675+
"v_11 frozen<%s>"
674676
")" % (self.nested_tuples_schema_helper(1),
675677
self.nested_tuples_schema_helper(2),
676678
self.nested_tuples_schema_helper(3),
677-
self.nested_tuples_schema_helper(12)))
679+
self.nested_tuples_schema_helper(11)))
678680

679-
for i in (1, 2, 3, 12):
681+
for i in (1, 2, 3, 11):
680682
# create tuple
681683
created_tuple = self.nested_tuples_creator_helper(i)
682684

tests/integration/standard/test_udts.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,12 @@ def test_can_insert_nested_registered_udts(self):
389389
with self._cluster_default_dict_factory() as c:
390390
s = c.connect(self.keyspace_name, wait_for_all_pools=True)
391391

392-
max_nesting_depth = 12
392+
# Scylla caps CQL expression nesting depth at 12 (every recursive
393+
# `term` counts). A UDT literal `{value: ...}` adds two term levels
394+
# per nesting, so a UDT literal inserted via a simple statement can
395+
# be at most 10 levels deep before the server rejects it with
396+
# "expression nested too deeply".
397+
max_nesting_depth = 10
393398

394399
# create the schema
395400
self.nested_udt_schema_helper(s, max_nesting_depth)
@@ -454,7 +459,12 @@ def test_can_insert_nested_registered_udts_with_different_namedtuples(self):
454459
with self._cluster_default_dict_factory() as c:
455460
s = c.connect(self.keyspace_name, wait_for_all_pools=True)
456461

457-
max_nesting_depth = 12
462+
# Scylla caps CQL expression nesting depth at 12 (every recursive
463+
# `term` counts). A UDT literal `{value: ...}` adds two term levels
464+
# per nesting, so a UDT literal inserted via a simple statement can
465+
# be at most 10 levels deep before the server rejects it with
466+
# "expression nested too deeply".
467+
max_nesting_depth = 10
458468

459469
# create the schema
460470
self.nested_udt_schema_helper(s, max_nesting_depth)

0 commit comments

Comments
 (0)