Traceback when adding Repository to config file #794

Closed
opened 2023-11-24 14:10:46 +00:00 by Jacksaur · 4 comments

What I'm trying to do and why

When adding a repository to my config file, running borgmatic config validate to check results in a Python traceback.
The validate command worked perfectly when I used the example generated config and edited its paths directly, but the issue started when I tried to add a second repository. While attempting to locate the cause of the issue, I must have messed with the example config layout, as now the repository line will cause a traceback no matter what.

Traceback (most recent call last):
  File "/usr/local/bin/borgmatic", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borgmatic/commands/borgmatic.py", line 844, in main
    configs, parse_logs = load_configurations(
                          ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borgmatic/commands/borgmatic.py", line 513, in load_configurations
    configs[config_filename], parse_logs = validate.parse_configuration(
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borgmatic/config/validate.py", line 118, in parse_configuration
    logs = normalize.normalize(config_filename, config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/borgmatic/config/normalize.py", line 211, in normalize
    repository_path = repository_dict['path']
                      ~~~~~~~~~~~~~~~^^^^^^^^
TypeError: string indices must be integers, not 'str'

Removing the repository entries entirely results in the validate passing (Whilst warning that a repository hasn't been provided, of course).
As far as I can tell, my config file is formatted correctly. I've even directly pasted in the values from the example config hosted online, but still get a traceback.

Could my text editor be messing with the spacing or something somehow?

Steps to reproduce

Use attached config file with Borgmatic.
borgmatic config validate will result in a traceback.
Remove repository entries.
Config will validate successfully.

Actual behavior

No response

Expected behavior

No response

Other notes / implementation ideas

No response

borgmatic version

1.8.5

borgmatic installation method

Docker

Borg version

1.2.6

Python version

3.11.5

Database version (if applicable)

No response

Operating system and version

Host: Debian Container: Alpine

### What I'm trying to do and why When adding a repository to my config file, running `borgmatic config validate` to check results in a Python traceback. The validate command worked perfectly when I used the example generated config and edited its paths directly, but the issue started when I tried to add a second repository. While attempting to locate the cause of the issue, I must have messed with the example config layout, as now the repository line will cause a traceback no matter what. ``` Traceback (most recent call last): File "/usr/local/bin/borgmatic", line 8, in <module> sys.exit(main()) ^^^^^^ File "/usr/local/lib/python3.11/site-packages/borgmatic/commands/borgmatic.py", line 844, in main configs, parse_logs = load_configurations( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/borgmatic/commands/borgmatic.py", line 513, in load_configurations configs[config_filename], parse_logs = validate.parse_configuration( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/borgmatic/config/validate.py", line 118, in parse_configuration logs = normalize.normalize(config_filename, config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/borgmatic/config/normalize.py", line 211, in normalize repository_path = repository_dict['path'] ~~~~~~~~~~~~~~~^^^^^^^^ TypeError: string indices must be integers, not 'str' ``` Removing the repository entries entirely results in the validate passing (Whilst warning that a repository hasn't been provided, of course). As far as I can tell, my config file is formatted correctly. I've even directly pasted in the values from the example config hosted online, but still get a traceback. Could my text editor be messing with the spacing or something somehow? ### Steps to reproduce Use attached config file with Borgmatic. `borgmatic config validate` will result in a traceback. Remove repository entries. Config will validate successfully. ### Actual behavior _No response_ ### Expected behavior _No response_ ### Other notes / implementation ideas _No response_ ### borgmatic version 1.8.5 ### borgmatic installation method Docker ### Borg version 1.2.6 ### Python version 3.11.5 ### Database version (if applicable) _No response_ ### Operating system and version Host: Debian Container: Alpine
1.9 KiB
Owner

What's going on is that borgmatic is interpreting the - .nobackup list item as part of the repositories list since it's not commented out—resulting in the traceback you're seeing. The work-around is to comment out that line so that it isn't treated as a repository.

I'm going to mark this as a bug though because an invalid configuration file shouldn't result in a borgmatic traceback.

What's going on is that borgmatic is interpreting the `- .nobackup` list item as part of the repositories list since it's not commented out—resulting in the traceback you're seeing. The work-around is to comment out that line so that it isn't treated as a repository. I'm going to mark this as a bug though because an invalid configuration file shouldn't result in a borgmatic traceback.
witten added the
bug
label 2023-11-24 17:42:27 +00:00
Author

Argh, I expected it'd be something silly with the formatting. I must have forgotten to uncomment the rest of the nobackup section when setting up. Cheers.

Argh, I expected it'd be something silly with the formatting. I must have forgotten to uncomment the rest of the nobackup section when setting up. Cheers.
Owner

Fixed in main!

Fixed in main!
Owner

Released in borgmatic 1.8.6!

Released in borgmatic 1.8.6!
Sign in to join this conversation.
No Milestone
No Assignees
2 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#794
No description provided.