Open yadobler opened 2 weeks ago
Thanks for mentioning this issue, I think it's mentioned in the User Guide under note of the command edit
. Because index is positive integer, so 0 is considered as invalid command, while out of bound positive integers are considered invalid index.
Team chose [response.NotInScope
]
Reason for disagreement: ### As a user
edit
command correctly, but I did format edit <index> <editable parameter>
correctly:
0
).n/
).if "(edit) 0 is considered as invalid command", why is edit 1 n/!@#!@#
not an invalid command, but instead a valid command with a specific "incorrect name parameter" error message:
This would also be an invalid command
since "name" is alphanumeric+space, just like how "index" is a positive integer. This actually confused me more since I am incorrectly led to assume that if the prefixed parameters have customised validity errors, then "index" would also have one (or that the "The person index provided is invalid"
error would apply to this as well - since it is not specifically that "There exists no user at index X" but a more general "index invalid".
0
as index is not a harmful input since:
0
instead of 9
as a typo; or 0
.
This ties back to (3) where I would not realise the 0
is actually the issue. Since the error states the "command format" is incorrect, the user will be focused on the format itself, and skip over the note stating the index is positive integer. 0
is invalid, just that the index is a value like 1, 2, 3,...
and relies on the user to understand the meaning of "positive integer".Command
interface object in the CommandParser
interface class (specifically editCommand
and editCommandParser
). The preamble from the ArgumentTokenizer
seems to be unable to handle the index 0
and errors out but caught as an exception while collecting the arguments - as opposed to after collecting and passing the tokens into the ParserUtil
where individual checks happen and "Invalid Index" is thrown. (that is my understanding from the DG). This means that there is a code smell somewhere, and edge cases like point (5) are not caught or anticipated.
Summary
When the Index for a command (e.g. edit) is 0, the error given is related to "invalid command format", but when the Index given is more than the number of items listed, the error given is instead "The person index is invalid".
Steps to reproduce
edit 0 n/test
edit 100 n/test
given the number of persons listed is less than 100Expected
Both result in "The person index is invalid".
Observed
edit 0 n/test
edit 100 n/test
Tester Information
System Information:
Java version: