Unrecognized argument when multiple different actions have the same flag value #881
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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: 1where1is the flag's value.Steps to reproduce
Actual behavior
Expected behavior
The arguments parse and the borgmatic
checkaction 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 1is a flag and value for the global action and--match-archives 1is a flag and (the same) value for thecheckaction. But if the--match-archivesvalue 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
Fixed in main. Will be part of the next release.
Released in borgmatic 1.8.12!