From 823d13ced0753670c7fb10de1c4329a7f4581006 Mon Sep 17 00:00:00 2001 From: sylwiaszunejko Date: Wed, 10 Jun 2026 13:32:29 +0200 Subject: [PATCH] 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. --- tests/integration/standard/test_types.py | 12 +++++++----- tests/integration/standard/test_udts.py | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/integration/standard/test_types.py b/tests/integration/standard/test_types.py index 6bf25ce163..d742f84ffb 100644 --- a/tests/integration/standard/test_types.py +++ b/tests/integration/standard/test_types.py @@ -663,20 +663,22 @@ def test_can_insert_nested_tuples(self): s.encoder.mapping[tuple] = s.encoder.cql_encode_tuple # create a table with multiple sizes of nested tuples - # Note: Scylla limits CQL expression nesting depth to 12, so the - # deepest tuple tested here is 12 levels deep. + # Note: Scylla limits CQL expression nesting depth to 12 (every + # recursive `term` counts, including the innermost scalar value), so a + # nested tuple literal can be at most 11 levels deep before the server + # rejects it with "expression nested too deeply". s.execute("CREATE TABLE nested_tuples (" "k int PRIMARY KEY, " "v_1 frozen<%s>," "v_2 frozen<%s>," "v_3 frozen<%s>," - "v_12 frozen<%s>" + "v_11 frozen<%s>" ")" % (self.nested_tuples_schema_helper(1), self.nested_tuples_schema_helper(2), self.nested_tuples_schema_helper(3), - self.nested_tuples_schema_helper(12))) + self.nested_tuples_schema_helper(11))) - for i in (1, 2, 3, 12): + for i in (1, 2, 3, 11): # create tuple created_tuple = self.nested_tuples_creator_helper(i) diff --git a/tests/integration/standard/test_udts.py b/tests/integration/standard/test_udts.py index 7533601757..520df49413 100644 --- a/tests/integration/standard/test_udts.py +++ b/tests/integration/standard/test_udts.py @@ -389,7 +389,12 @@ def test_can_insert_nested_registered_udts(self): with self._cluster_default_dict_factory() as c: s = c.connect(self.keyspace_name, wait_for_all_pools=True) - max_nesting_depth = 12 + # Scylla caps CQL expression nesting depth at 12 (every recursive + # `term` counts). A UDT literal `{value: ...}` adds two term levels + # per nesting, so a UDT literal inserted via a simple statement can + # be at most 10 levels deep before the server rejects it with + # "expression nested too deeply". + max_nesting_depth = 10 # create the schema self.nested_udt_schema_helper(s, max_nesting_depth) @@ -454,7 +459,12 @@ def test_can_insert_nested_registered_udts_with_different_namedtuples(self): with self._cluster_default_dict_factory() as c: s = c.connect(self.keyspace_name, wait_for_all_pools=True) - max_nesting_depth = 12 + # Scylla caps CQL expression nesting depth at 12 (every recursive + # `term` counts). A UDT literal `{value: ...}` adds two term levels + # per nesting, so a UDT literal inserted via a simple statement can + # be at most 10 levels deep before the server rejects it with + # "expression nested too deeply". + max_nesting_depth = 10 # create the schema self.nested_udt_schema_helper(s, max_nesting_depth)