Task #2380
Story #2045: Get the DataONE CLI ready for public release
CLI sliently ignores invalid boolean values
100%
Description
It is possible to set the variable "verbose" to a value of "@fred@". No error is thrown and the value remains unchanged.
The CLI should report invalid values, and allow for case insensitive boolean values ("@true@", "@True@", "@tRuE@" should all succeed).
History
#1 Updated by Andrew Pippin almost 13 years ago
- Category set to d1_client_cli
- Assignee set to Andrew Pippin
Updated Assinged_To and Category.
#2 Updated by Matthew Jones almost 13 years ago
- Tracker changed from Task to Bug
- Target version set to Sprint-2012.07-Block.1.4
- Parent task set to #2045
#3 Updated by Roger Dahl almost 13 years ago
This is caused by a design decision that might not be a good one. The issue is that in order to easily support session variables that are unset (None), boolean, integers or strings, I implemented those as native Python variables and parse them as such. It makes things very clear in the code, but it causes some unexpected results, such as being able to have "fred" a valid value for True, simply because the string "fred" evaluates to True in Python.
So, a value can be set to False by passing in values that evaluate to False in Python, such as "0" and False. It can be set to True with "1", and "fred". It can be set to None by passing "None" (for which the clear command is a shortcut).
#4 Updated by Andrew Pippin over 12 years ago
Roger is correct. "fred" is a valid value. At first glance, the result is unexpected, but it shouldn't have been.
A possible solution would be to have a "validator" hook for each session variable. This would also help with #2377 "Verify that the object format is valid in CLI".
#5 Updated by Andrew Pippin over 12 years ago
- Status changed from New to In Progress
Valid boolean values are:
TRUE: ('true', 'True', 't', 'T', 1, 'yes', 'Yes' )
FALSE: ('false', 'False', 'f', 'F', 0, 'no', 'No' )
#6 Updated by Andrew Pippin over 12 years ago
- % Done changed from 0 to 100
- Status changed from In Progress to Closed
SVN commit 7246.