maedhroz commented on code in PR #4406:
URL: https://github.com/apache/cassandra/pull/4406#discussion_r2392850404


##########
src/java/org/apache/cassandra/config/GuardrailsOptions.java:
##########
@@ -1424,12 +1471,42 @@ private static Set<String> 
validateTableProperties(Set<String> properties, Strin
         Set<String> diff = Sets.difference(lowerCaseProperties, 
TableAttributes.allKeywords());
 
         if (!diff.isEmpty())
-            throw new IllegalArgumentException(format("Invalid value for %s: 
'%s' do not parse as valid table properties",
-                                                      name, diff));
+            throw new IllegalArgumentException(invalidValueMessage(name, diff, 
"table"));
 
         return lowerCaseProperties;
     }
 
+    private static Set<String> validateKeyspaceProperties(Set<String> 
properties, String name)
+    {
+        if (properties == null)
+            throw new IllegalArgumentException(format("Invalid value for %s: 
null is not allowed", name));
+
+        Set<String> lowerCaseProperties = 
properties.stream().map(LocalizeString::toLowerCaseLocalized).collect(toSet());
+        
+        if (lowerCaseProperties.contains("replication"))
+            throw new IllegalArgumentException(invalidValueMessage(name, 
Set.of("replication"), "keyspace"));
+
+        Set<String> diff = Sets.difference(lowerCaseProperties, 
KeyspaceAttributes.allKeywords());
+
+        if (!diff.isEmpty())
+            throw new IllegalArgumentException(invalidValueMessage(name, diff, 
"keyspace"));
+
+        return lowerCaseProperties;
+    }
+
+    public static String invalidValueMessage(String name, Set<String> 
invalidProperties, String type)
+    {
+        if (type.equals("keyspace") && 
invalidProperties.contains("replication"))
+            return format("Invalid value for %s: %s is a required keyspace 
property", name, invalidProperties);

Review Comment:
   I would just inline this in `validateKeyspaceProperties()` for now, so we're 
not doing the contains check for "replication" twice. If something else needs 
to do this in the future, we can always factor it out.



-- 
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