Bug 1150156 - snapper create: misleading error message
snapper create: misleading error message
Status: RESOLVED FIXED
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Basesystem
Current
Other Other
: P4 - Low : Minor (vote)
: ---
Assigned To: Arvin Schnell
E-mail List
https://trello.com/c/GpUTFJbS
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-09-10 11:49 UTC by Sergio Lindo Mansilla
Modified: 2020-08-31 11:40 UTC (History)
3 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Lindo Mansilla 2019-09-10 11:49:23 UTC
When snapper create is executed with an unknown parameter, the message creates confusion: "Command 'create' does not take arguments."

Including devel project filesystems:snapper/snapper -> snapper-0.8.3/client/snapper.cc, the command does accept arguments:
 625 void
 626 command_create(ProxySnappers* snappers, ProxySnapper* snapper)
 627 {
 628     const struct option options[] = {
 629   { "type",   required_argument,  0,  't' },
 630   { "pre-number",   required_argument,  0,  0 },
 631   { "print-number", no_argument,    0,  'p' },
 632   { "description",  required_argument,  0,  'd' },
 633   { "cleanup-algorithm",  required_argument,  0,  'c' },
 634   { "userdata",   required_argument,  0,  'u' },
 635   { "command",    required_argument,  0,  0 },
 636   { 0, 0, 0, 0 }
 637     };
 638 
 639     GetOpts::parsed_opts opts = getopts.parse("create", options);
 640     if (getopts.hasArgs())
 641     {
 642   cerr << _("Command 'create' does not take arguments.") << endl;                                                                                                                                                                        
 643   exit(EXIT_FAILURE);
 644     }

But, the message is wrong.

Reproducible:
Having an openSUSE/SLE installation with enabled BTRFS snapshots, execute:
# snapper create -type single -d "single snapshot"
Notice the bad argument -type.
Comment 1 David Diaz 2019-09-11 10:02:12 UTC
Thank you Sergio.

Maybe the error message could be improved a little bit.
Comment 2 Sergio Lindo Mansilla 2019-09-11 10:34:37 UTC
I forgot to state a expected result:

"Invalid parameter for command 'create'."
Comment 3 Arvin Schnell 2020-08-25 10:23:09 UTC
Well, the error message is not wrong. The problem is that the invocation
contains two errors: 1. The type is "ype" and 2. an additional argument
is provided. snapper reports the second error.

This is like with the --width option of ls:

# ls --width 1000
ok

# ls -width 1000
ls: invalid line width: ‘idth’

# ls -w1000 1000
ls: cannot access '1000': No such file or directory

So ls also reports just one error but the other one.

A better result for snapper could be:

# snapper create -type single
Unknown snapshot type 'ype'.
Comment 4 Arvin Schnell 2020-08-28 06:34:23 UTC
I found some real bugs in the error handling for getopt in snapper:

# snapper create -pt
Missing argument for command option '-pt'.

The error should only mention '-t' or '--type' that needs the argument.

# snapper create -px
Unknown option '-px' for command 'create'.

The error should only mention '-x'.
Comment 5 Arvin Schnell 2020-08-31 10:49:46 UTC
PR: https://github.com/openSUSE/snapper/pull/550
Comment 6 Arvin Schnell 2020-08-31 11:40:32 UTC
SR: https://build.opensuse.org/request/show/830770