Check Prop Value Format and Key types.#3146
Conversation
ctubbsii
left a comment
There was a problem hiding this comment.
Ideally we'd validate property values on the server side, and reject the RPC request (and propagate the error through the public API call), when validation fails.
|
I think the fix, when ready, can be applied to the 2.1 branch. This PR is currently targeting the main branch. If you cherry-pick the changes to a 2.1 bugfix branch, and force push to the branch that is backing this PR, we can edit the PR's base branch to make this a PR against 2.1. |
|
If possible, it would be nice to add an IT to the ShellIT that exercises setting a prop w/ a bad value. |
Is there a bigger problem here? Re my comment earlier about testing the shell, it might be nice to have an IT for the public API also that tries to set a bad value if we do not have one. |
Yep, I'm working on that now. I think it's also valuable to have the shell perform validation and not issue the RPC request in the first place. |
| } | ||
|
|
||
| private void validatePropertyType(String property, String value, String fullCommand, | ||
| String tableName) throws BadArgumentException { |
There was a problem hiding this comment.
It looks like instead of tableName the parameter is more generic name (either table name of namespace name)
There was a problem hiding this comment.
I'm not sure how to determine the best fix for this since namespace and table don't have good property separation.
Only ValidTableProperties are defined in Property.java.
There is not a separate ValidNamespaceProperties hashset defined.
accumulo/core/src/main/java/org/apache/accumulo/core/conf/Property.java
Lines 1378 to 1381 in 339672a
You can also see the interchangeability in the property set code for namespace. It's just checking if it's a valid table property vs anything namespace specific.
So, should namespaces have separate properties that aren't table properties?
if so, I can rework this and also add a isValidNamespacePropertyKey method to Property.java
There was a problem hiding this comment.
Properties are a hierarchy default <- system <- namespace <- table with the more specific overriding the more generic. I'm not sure of the top of my head, but I expect that all table properties are valid namespace properties. There may be a few specific system only props, but in general they should also be override-able in a namespace or table.
The shell config command was only checking Property Key Types and not Value Formats on Set operations. Changed Set operation to also validate value types to ensure proper format before setting properties.
Added IT test for checking property types using shell commands. Refactored ConfigCommand.java to reduce code duplication.
339672a to
8ecfdc5
Compare
|
I've thought about these changes and I'm closing this PR in favor of the fix in #3177 |
relates to #3145
The shell config command was only checking Property Key Types and not Value Formats on Set operations. Changed Set operation to also validate value types to ensure proper format before setting properties.
This changes the shell client behavior to now throw an error message to the user on an invalid property setting.
Boolean Example:
Port Example:
This PR is staged against main, but we may want to backport this change.