Copilot commented on code in PR #4596:
URL: https://github.com/apache/cassandra/pull/4596#discussion_r2878549484


##########
src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java:
##########
@@ -409,7 +409,21 @@ public void validate(ClientState state) throws 
InvalidRequestException
         checkFalse(isVirtual() && hasConditions(), "Conditional updates are 
not supported by virtual tables");
 
         if (attrs.isTimestampSet())
+        {
             Guardrails.userTimestampsEnabled.ensureEnabled(state);
+        }
+        // Misprepare guardrail shouldn't block system keyspaces
+        if (SchemaConstants.isSystemKeyspace(metadata.keyspace))
+            return;
+
+        boolean hasRestriction = restrictions != null &&
+                                 restrictions.hasPartitionKeyRestrictions() ||
+                                 
restrictions.hasClusteringColumnsRestrictions() ||
+                                 restrictions.hasNonPrimaryKeyRestrictions();

Review Comment:
   `hasRestriction` mixes `&&` and `||` without parentheses. If `restrictions` 
is null, the `||` terms will still be evaluated and can throw an NPE; even when 
non-null, the current precedence makes the intent unclear. Wrap the OR-ed 
restriction checks in parentheses so the null-check guards all of them 
(matching the pattern used in `SelectStatement`).
   ```suggestion
                                    (restrictions.hasPartitionKeyRestrictions() 
||
                                     
restrictions.hasClusteringColumnsRestrictions() ||
                                     
restrictions.hasNonPrimaryKeyRestrictions());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to