Using "label: {constant}" fails #1155

Closed
opened 2025-10-01 09:53:34 +00:00 by kimheino · 2 comments
Contributor

What I'm trying to do and why

I'm trying to convert my multiple almost identical yaml files to use constants and include.

Steps to reproduce

borgmatic.d/test.yaml is:

constants:
    company: test

<<: !include /etc/borgmatic/common.yaml

borgmatic/common.yaml has:

...
repositories:
    - path: ssh://xxx@xxx.your-storagebox.de:23/./borg_www_{company}
      label: {company}
...

That fails with:

/etc/borgmatic.d/test.yaml: Error parsing configuration file
An error occurred while parsing a configuration file at /etc/borgmatic.d/test.yaml:
At 'repositories[0].label': {'company': None} is not of type 'string'

This works correctly, creating label "foo-test":

repositories:
    - path: ssh://xxx@xxx.your-storagebox.de:23/./borg_www_{company}
      label: foo-{company}

This fails too:

      label: {company}-foo

Actual behavior

No response

Expected behavior

label: {company} should work.

Other notes / implementation ideas

No response

borgmatic version

2.0.8

borgmatic installation method

No response

Borg version

No response

Python version

No response

Database version (if applicable)

No response

Operating system and version

No response

### What I'm trying to do and why I'm trying to convert my multiple almost identical yaml files to use `constants` and `include`. ### Steps to reproduce borgmatic.d/test.yaml is: ``` constants: company: test <<: !include /etc/borgmatic/common.yaml ``` borgmatic/common.yaml has: ``` ... repositories: - path: ssh://xxx@xxx.your-storagebox.de:23/./borg_www_{company} label: {company} ... ``` That fails with: ``` /etc/borgmatic.d/test.yaml: Error parsing configuration file An error occurred while parsing a configuration file at /etc/borgmatic.d/test.yaml: At 'repositories[0].label': {'company': None} is not of type 'string' ``` This works correctly, creating label "foo-test": ``` repositories: - path: ssh://xxx@xxx.your-storagebox.de:23/./borg_www_{company} label: foo-{company} ``` This fails too: ``` label: {company}-foo ``` ### Actual behavior _No response_ ### Expected behavior `label: {company}` should work. ### Other notes / implementation ideas _No response_ ### borgmatic version 2.0.8 ### borgmatic installation method _No response_ ### Borg version _No response_ ### Python version _No response_ ### Database version (if applicable) _No response_ ### Operating system and version _No response_
Owner

Try changing this:

      label: {company}

... to this:

      label: "{company}"

In YAML, a value like {company} without quotes will be interpreted as a mapping (with an empty value). However, label requires a plain string. That's why you're getting the error.

Try changing this: ```yaml label: {company} ``` ... to this: ```yaml label: "{company}" ``` In YAML, a value like `{company}` without quotes will be interpreted as a mapping (with an empty value). However, `label` requires a plain string. That's why you're getting the error.
witten added the question / support label 2025-10-02 00:53:11 +00:00
Author
Contributor

Ah of course. Thank you.

Ah of course. Thank you.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#1155