Unrecognized argument when multiple different actions have the same flag value #881

Closed
opened 2024-06-20 18:51:34 +00:00 by witten · 2 comments
Owner

What I'm trying to do and why

I'm trying to run a borgmatic action that receives a command-line flag (as part of testing an unrelated ticket's implementation), but I'm receiving an error: Unrecognized argument: 1 where 1 is the flag's value.

Steps to reproduce

borgmatic -c test.yaml -v 1 check --match-archives 1

Actual behavior

usage: borgmatic [-h] [-c CONFIG_PATHS] [-n] [-nc] [-v {-2,-1,0,1,2}] [--syslog-verbosity {-2,-1,0,1,2}] [--log-file-verbosity {-2,-1,0,1,2}]
                 [--monitoring-verbosity {-2,-1,0,1,2}] [--log-file LOG_FILE] [--log-file-format LOG_FILE_FORMAT] [--log-json]
                 [--override OPTION.SUBOPTION=VALUE] [--no-environment-interpolation] [--bash-completion] [--fish-completion] [--version]
                 ...
Unrecognized argument: 1

Need some help? https://torsion.org/borgmatic/#issues

Expected behavior

The arguments parse and the borgmatic check action proceeds.

Other notes / implementation ideas

This only happens when a flag's value is present for multiple actions in the command-line. For instance, here -v 1 is a flag and value for the global action and --match-archives 1 is a flag and (the same) value for the check action. But if the --match-archives value is changed to anything else, there is no error.

This occurs because of an unfortunate bug in get_unparsable_arguments(); it's blindly looking for any argument strings that show up across actions, treating them as "unparsable" arguments that no actions have consumed. And those get reported as unrecognized arguments to the user.

borgmatic version

1.8.11 or main

borgmatic installation method

pipx install --editable

Borg version

1.2.8

Python version

3.12.3

Database version (if applicable)

No response

Operating system and version

Manjaro stable

### What I'm trying to do and why I'm trying to run a borgmatic action that receives a command-line flag (as part of testing an unrelated ticket's implementation), but I'm receiving an error: `Unrecognized argument: 1` where `1` is the flag's value. ### Steps to reproduce ```bash borgmatic -c test.yaml -v 1 check --match-archives 1 ``` ### Actual behavior ``` usage: borgmatic [-h] [-c CONFIG_PATHS] [-n] [-nc] [-v {-2,-1,0,1,2}] [--syslog-verbosity {-2,-1,0,1,2}] [--log-file-verbosity {-2,-1,0,1,2}] [--monitoring-verbosity {-2,-1,0,1,2}] [--log-file LOG_FILE] [--log-file-format LOG_FILE_FORMAT] [--log-json] [--override OPTION.SUBOPTION=VALUE] [--no-environment-interpolation] [--bash-completion] [--fish-completion] [--version] ... Unrecognized argument: 1 Need some help? https://torsion.org/borgmatic/#issues ``` ### Expected behavior The arguments parse and the borgmatic `check` action proceeds. ### Other notes / implementation ideas This only happens when a flag's value is present for multiple actions in the command-line. For instance, here `-v 1` is a flag and value for the global action and `--match-archives 1` is a flag and (the same) value for the `check` action. But if the `--match-archives` value is changed to anything else, there is no error. This occurs because of an unfortunate bug in `get_unparsable_arguments()`; it's blindly looking for any argument strings that show up _across_ actions, treating them as "unparsable" arguments that no actions have consumed. And those get reported as unrecognized arguments to the user. ### borgmatic version 1.8.11 or main ### borgmatic installation method pipx install --editable ### Borg version 1.2.8 ### Python version 3.12.3 ### Database version (if applicable) _No response_ ### Operating system and version Manjaro stable
witten added the
bug
label 2024-06-20 18:51:38 +00:00
Author
Owner

Fixed in main. Will be part of the next release.

Fixed in main. Will be part of the next release.
Author
Owner

Released in borgmatic 1.8.12!

Released in borgmatic 1.8.12!
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#881
No description provided.