Traceback when usage error occurs #768

Closed
opened 2023-10-07 01:42:33 +00:00 by witten · 2 comments
Owner

What I'm trying to do and why

As part of prototyping another feature, I accidentally ran borgmatic with an invalid argument. However this produced a traceback instead of a nice usage error message.

Steps to reproduce

$ borgmatic --invalid

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]
                 ...
Traceback (most recent call last):
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 816, in main
    arguments = parse_arguments(*sys.argv[1:])
  File "/home/witten/code/borgmatic/borgmatic/commands/arguments.py", line 1283, in parse_arguments
    raise ValueError(
ValueError: Unrecognized argument: --invalid

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/root/.local/bin/borgmatic", line 8, in <module>
    sys.exit(main())
  File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 818, in main
    configure_logging(logging.CRITICAL)
  File "/home/witten/code/borgmatic/borgmatic/logger.py", line 170, in configure_logging
    syslog_log_level = logging.DISABLED
AttributeError: module 'logging' has no attribute 'DISABLED'

Expected 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: --invalid

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

Other notes / implementation ideas

This problem appears to have been introduced in borgmatic 1.8.3, and in particular I'm guessing it was the logging changes as part of #665.

borgmatic version

1.8.3 or main

borgmatic installation method

pipx install --editable

Borg version

1.2.3

Python version

3.10.10

Database version (if applicable)

No response

Operating system and version

Manjaro stable

### What I'm trying to do and why As part of prototyping another feature, I accidentally ran borgmatic with an invalid argument. However this produced a traceback instead of a nice usage error message. ### Steps to reproduce ``` $ borgmatic --invalid ``` ### 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] ... Traceback (most recent call last): File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 816, in main arguments = parse_arguments(*sys.argv[1:]) File "/home/witten/code/borgmatic/borgmatic/commands/arguments.py", line 1283, in parse_arguments raise ValueError( ValueError: Unrecognized argument: --invalid During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/root/.local/bin/borgmatic", line 8, in <module> sys.exit(main()) File "/home/witten/code/borgmatic/borgmatic/commands/borgmatic.py", line 818, in main configure_logging(logging.CRITICAL) File "/home/witten/code/borgmatic/borgmatic/logger.py", line 170, in configure_logging syslog_log_level = logging.DISABLED AttributeError: module 'logging' has no attribute 'DISABLED' ``` ### Expected 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: --invalid Need some help? https://torsion.org/borgmatic/#issues ``` ### Other notes / implementation ideas This problem appears to have been introduced in borgmatic 1.8.3, and in particular I'm guessing it was the logging changes as part of #665. ### borgmatic version 1.8.3 or main ### borgmatic installation method pipx install --editable ### Borg version 1.2.3 ### Python version 3.10.10 ### Database version (if applicable) _No response_ ### Operating system and version Manjaro stable
witten added the
bug
label 2023-10-07 01:43:06 +00:00
Author
Owner

Fixed in main. The fix will be part of the next release.

Fixed in main. The fix will be part of the next release.
Author
Owner

Released in borgmatic 1.8.4!

Released in borgmatic 1.8.4!
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#768
No description provided.