Skip to content

Commit 9d24352

Browse files
Validate scope in Session.wait_for_schema_agreement
The docstring promised ValueError for an invalid scope, but no check existed: an unknown value silently fell through to cluster-wide behaviour. Coerce/validate the argument against SchemaAgreementScope up front (also accepting the plain string values) and raise a clear ValueError listing the valid scopes.
1 parent da4d3c4 commit 9d24352

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

cassandra/cluster.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3482,6 +3482,14 @@ def wait_for_schema_agreement(self, wait_time: Optional[float] = None,
34823482
if wait_time is not None and wait_time <= 0:
34833483
raise ValueError("wait_time must be greater than 0")
34843484

3485+
try:
3486+
scope = SchemaAgreementScope(scope)
3487+
except ValueError:
3488+
raise ValueError(
3489+
"scope must be one of %s" % (
3490+
[s.value for s in SchemaAgreementScope],)
3491+
)
3492+
34853493
total_timeout = wait_time if wait_time is not None else self.cluster.max_schema_agreement_wait
34863494
if total_timeout <= 0:
34873495
raise ValueError("total_timeout must be greater than 0")
@@ -5325,7 +5333,7 @@ def _execute_after_prepare(self, host, connection, pool, response):
53255333
new_metadata_id = response.result_metadata_id
53265334
if new_metadata_id is not None:
53275335
self.prepared_statement.result_metadata_id = new_metadata_id
5328-
5336+
53295337
# use self._query to re-use the same host and
53305338
# at the same time properly borrow the connection
53315339
if pool is None and connection is not None and connection.is_control_connection:

0 commit comments

Comments
 (0)