borgmatic configuration syntax for more granular exit codes (borg_exit_codes / exit_code / treat_as) on website does not match application syntax #1094

Closed
opened 2025-05-12 19:11:24 +00:00 by sgiebels · 4 comments

What I'm trying to do and why

I'm trying to ensure that if borg encounters an error, borgmatic will not ignore/hide it.
This in reference to another ticket I have created,
No error when one my source_directories is not mounted; default value of option 'source_directories_must_exist'

To archieve this, I am following the instructions on:
borgmatic - How to customize warnings and errors - More granular configuration

Steps to reproduce

I've added the following configuration to my borgmatic configuration file:

borg_exit_codes:
    - exit_code: 1
      treat_as: error
    - exit_code: 100
      treat_as: error
    - exit_code: 101
      treat_as: error
    - exit_code: 102
      treat_as: error
    - exit_code: 103
      treat_as: error
    - exit_code: 104
      treat_as: error
    - exit_code: 105
      treat_as: error
    - exit_code: 106
      treat_as: error
    - exit_code: 107
      treat_as: error

and run borgmatic:

# borgmatic --config borgmatic_backup_mnt_mountpoint_directory.yaml create --verbosity 2 --list --stats --log-json

Actual behavior

I get the following error:

borgmatic_backup_mnt_mountpoint_directory.yaml: No valid configuration files found

summary:
/mnt/data/borgmatic.d/borgmatic_backup_mnt_mountpoint_directory.yaml: Error parsing configuration file
An error occurred while parsing a configuration file at /mnt/data/borgmatic.d/borgmatic_backup_mnt_mountpoint_directory.yaml:
At 'borg_exit_codes[0]': Additional properties are not allowed ('exit_code' was unexpected)
At 'borg_exit_codes[0]': 'code' is a required property

Expected behavior

I had expected this parameter to be correct.

Other notes / implementation ideas

I've tried replacing the key 'exit_code' with 'code', and this seems to work (i.e. the configuration syntax is accepted), which makes me believe that there is a mismatch between the code and the documentation describing the syntax.

borgmatic version

2.0.5

borgmatic installation method

pipx

Borg version

borg 1.4.1

Python version

Python 3.11.2

Database version (if applicable)

No response

Operating system and version

Debian GNU/Linux 12 (bookworm)

### What I'm trying to do and why I'm trying to ensure that if borg encounters an error, borgmatic will not ignore/hide it. This in reference to another ticket I have created, [No error when one my source_directories is not mounted; default value of option 'source_directories_must_exist' ](https://projects.torsion.org/borgmatic-collective/borgmatic/issues/1092) To archieve this, I am following the instructions on: [borgmatic - How to customize warnings and errors - More granular configuration](https://torsion.org/borgmatic/docs/how-to/customize-warnings-and-errors/#more-granular-configuration) ### Steps to reproduce I've added the following configuration to my borgmatic configuration file: ``` borg_exit_codes: - exit_code: 1 treat_as: error - exit_code: 100 treat_as: error - exit_code: 101 treat_as: error - exit_code: 102 treat_as: error - exit_code: 103 treat_as: error - exit_code: 104 treat_as: error - exit_code: 105 treat_as: error - exit_code: 106 treat_as: error - exit_code: 107 treat_as: error ``` and run borgmatic: ``` # borgmatic --config borgmatic_backup_mnt_mountpoint_directory.yaml create --verbosity 2 --list --stats --log-json ``` ### Actual behavior I get the following error: ``` borgmatic_backup_mnt_mountpoint_directory.yaml: No valid configuration files found summary: /mnt/data/borgmatic.d/borgmatic_backup_mnt_mountpoint_directory.yaml: Error parsing configuration file An error occurred while parsing a configuration file at /mnt/data/borgmatic.d/borgmatic_backup_mnt_mountpoint_directory.yaml: At 'borg_exit_codes[0]': Additional properties are not allowed ('exit_code' was unexpected) At 'borg_exit_codes[0]': 'code' is a required property ``` ### Expected behavior I had expected this parameter to be correct. ### Other notes / implementation ideas I've tried replacing the key 'exit_code' with 'code', and this seems to work (i.e. the configuration syntax is accepted), which makes me believe that there is a mismatch between the code and the documentation describing the syntax. ### borgmatic version 2.0.5 ### borgmatic installation method pipx ### Borg version borg 1.4.1 ### Python version Python 3.11.2 ### Database version (if applicable) _No response_ ### Operating system and version Debian GNU/Linux 12 (bookworm)
Owner

Welp, looks like the docs are just plain wrong! Change exit_code: to code: and it should work for you. I'll update the docs.

Welp, looks like the docs are just plain wrong! Change `exit_code:` to `code:` and it should work for you. I'll update the docs.
Owner

Fixed in main! The updated docs should be live shortly. Thank you!

Fixed in main! The updated docs should be live shortly. Thank you!
Author
  1. Another small remark: The tab-size / indent on that website is 3 spaces, where on the other pages it is '4'

  2. I believe the following text on that same page is not correct anymore since Borg 1.4:

For instance, to elevate Borg warnings to errors, thereby causing borgmatic to error on them, use the following borgmatic configuration: ..

borg_exit_codes:
   - code: 1
     treat_as: error

Borg (>=1.4) returns extra warning exit codes (in the range 100..107) in addition to 'code: 1'. These warning exit codes won't match 'code==1', and thus won't make borgmatic elevate all warnings into an error.

I don't see any other way to elevate all warnings (code 1,100..107) into an error, other than to specify each of them:

borg_exit_codes:
    - code: 1
      treat_as: error
    - code: 100
      treat_as: error
    - code: 101
      treat_as: error
    - code: 102
      treat_as: error
    - code: 103
      treat_as: error
    - code: 104
      treat_as: error
    - code: 105
      treat_as: error
    - code: 106
      treat_as: error
    - code: 107
      treat_as: error
1. Another small remark: The tab-size / indent on that website is 3 spaces, where on the other pages it is '4' 2. I believe the following text on that same page is not correct anymore since Borg 1.4: > For instance, to elevate Borg warnings to errors, thereby causing borgmatic to error on them, use the following borgmatic configuration: .. > ``` > borg_exit_codes: > - code: 1 > treat_as: error > ``` Borg (>=1.4) returns extra warning exit codes (in the range 100..107) in addition to 'code: 1'. These warning exit codes won't match 'code==1', and thus won't make borgmatic elevate all warnings into an error. I don't see any other way to elevate all warnings (code 1,100..107) into an error, other than to specify each of them: ``` borg_exit_codes: - code: 1 treat_as: error - code: 100 treat_as: error - code: 101 treat_as: error - code: 102 treat_as: error - code: 103 treat_as: error - code: 104 treat_as: error - code: 105 treat_as: error - code: 106 treat_as: error - code: 107 treat_as: error ```
sgiebels reopened this issue 2025-05-12 20:11:47 +00:00
Owner

Another small remark: The tab-size / indent on that website is 3 spaces, where on the other pages it is '4'

Fixed, thank you!

I believe the following text on that same page is not correct anymore since Borg 1.4:

Good catch! I'll clarify that that approach is only for Borg < 1.4.

I don't see any other way to elevate all warnings into an error, except than to duplicate the syntax below for every value of N in range 100..107:

That's correct.

> Another small remark: The tab-size / indent on that website is 3 spaces, where on the other pages it is '4' Fixed, thank you! > I believe the following text on that same page is not correct anymore since Borg 1.4: Good catch! I'll clarify that that approach is only for Borg < 1.4. > I don't see any other way to elevate all warnings into an error, except than to duplicate the syntax below for every value of N in range 100..107: That's correct.
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#1094
No description provided.