colon is not allowed inside message strings in hooks #708

Closed
opened 2023-06-03 14:39:42 +00:00 by marozsas · 2 comments

What I'm trying to do and why

Display progress on console using the provided hooks.

Steps to reproduce (if a bug)

This cause the error when parsing the config file:

hooks:
  before_backup:
    - /bin/echo "Info: Starting a backup."

but this does not (apparently the colon in the message string is not escaped by the parser

hooks:
  before_backup:
    - /bin/echo "Info - Starting a backup."

Actual behavior (if a bug)

At 'hooks.before_backup[0]': {'echo "Info': 'Starting a backup."'} is not of type 'string'

Expected behavior (if a bug)

Using a colon in a string should be ok.

Other notes / implementation ideas

Environment

borgmatic version: borgmatic-1.7.10-1.1.noarch

Use sudo borgmatic --version or sudo pip show borgmatic | grep ^Version

borgmatic installation method: opensuse rpm package

Borg version: borgbackup-1.2.4-1.1.x86_64

Use sudo borg --version

Python version: NA

Use python3 --version

Database version (if applicable): NA

Use psql --version or mysql --version on client and server.

operating system and version: Opensuse tumbleweed 20230601

#### What I'm trying to do and why Display progress on console using the provided hooks. #### Steps to reproduce (if a bug) This cause the error when parsing the config file: ``` hooks: before_backup: - /bin/echo "Info: Starting a backup." ``` but this does not (apparently the colon in the message string is not escaped by the parser ``` hooks: before_backup: - /bin/echo "Info - Starting a backup." ``` #### Actual behavior (if a bug) ``` At 'hooks.before_backup[0]': {'echo "Info': 'Starting a backup."'} is not of type 'string' ``` #### Expected behavior (if a bug) Using a colon in a string should be ok. #### Other notes / implementation ideas #### Environment **borgmatic version:** borgmatic-1.7.10-1.1.noarch Use `sudo borgmatic --version` or `sudo pip show borgmatic | grep ^Version` **borgmatic installation method:** opensuse rpm package **Borg version:** borgbackup-1.2.4-1.1.x86_64 Use `sudo borg --version` **Python version:** NA Use `python3 --version` **Database version (if applicable):** NA Use `psql --version` or `mysql --version` on client and server. **operating system and version:** Opensuse tumbleweed 20230601
Owner

Thanks for reporting this! I've confirmed the behavior locally, but I'll have to dig in to see what's going on.

Thanks for reporting this! I've confirmed the behavior locally, but I'll have to dig in to see what's going on.
witten added the
bug
label 2023-06-03 17:02:04 +00:00
witten removed the
bug
label 2023-06-03 17:05:38 +00:00
Owner

Unfortunately, it looks like this is simply a YAML limitation; it's parsing the string with a colon as a mapping type. Here are two work-arounds though:

  1. Quote the entire command:
hooks:
  before_backup:
    - "/bin/echo Info: Starting a backup."
  1. Or use a multiline YAML string:
    before_actions:
        - >
      /bin/echo "Info: Starting a backup."      

What I'll do is change all the examples to quote the entire line and also document this issue. But beyond that, I don't think there's much I can do. Thanks!

Unfortunately, it looks like this is simply a YAML limitation; it's parsing the string with a colon as a mapping type. Here are two work-arounds though: 1. Quote the entire command: ```yaml hooks: before_backup: - "/bin/echo Info: Starting a backup." ``` 2. Or use a multiline YAML string: ```yaml before_actions: - > /bin/echo "Info: Starting a backup." ``` What I'll do is change all the examples to quote the entire line and also document this issue. But beyond that, I don't think there's much I can do. Thanks!
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#708
No description provided.