WARNING Variable "{name}" is not supported in the before create everything hook #1213

Closed
opened 2025-12-24 21:52:17 +00:00 by adatum Β· 7 comments

What I'm trying to do and why

When borgmatic runs i see this warning the logs:

WARNING Variable "{name}" is not supported in the before create everything hook

The relevant section of borgmatic's YAML config file contains the following line:

- runuser -l user -c 'dnf --cacheonly repoquery --qf "%{name}\n" --userinstalled > /home/user/Dropbox/userinstalled_$(hostname).txt'

{name} in this case is not a borgmatic variable, but a dnf variable in the command being run. However, it's not clear to me how to escape it.

This is not an urgent issue, as it is just a warning and the actual behavior is as desired.

Steps to reproduce

No response

Actual behavior

No response

Expected behavior

No response

Other notes / implementation ideas

No response

borgmatic version

2.0.12

borgmatic installation method

Fedora package

Borg version

borg 1.4.3

Python version

Python 3.14.2

Database version (if applicable)

No response

Operating system and version

Fedora 43

### What I'm trying to do and why When borgmatic runs i see this warning the logs: `WARNING Variable "{name}" is not supported in the before create everything hook` The relevant section of borgmatic's YAML config file contains the following line: `- runuser -l user -c 'dnf --cacheonly repoquery --qf "%{name}\n" --userinstalled > /home/user/Dropbox/userinstalled_$(hostname).txt'` `{name}` in this case is not a borgmatic variable, but a dnf variable in the command being run. However, it's not clear to me how to escape it. This is not an urgent issue, as it is just a warning and the actual behavior is as desired. ### Steps to reproduce _No response_ ### Actual behavior _No response_ ### Expected behavior _No response_ ### Other notes / implementation ideas _No response_ ### borgmatic version 2.0.12 ### borgmatic installation method Fedora package ### Borg version borg 1.4.3 ### Python version Python 3.14.2 ### Database version (if applicable) _No response_ ### Operating system and version Fedora 43
Owner

Thanks for taking the time to file this. I'll have to think about what if anything can be done about it. Maybe a YAML tag that flags the line as not to be warned about? A borgmatic option to disable the warnings altogether? Something else?

Thanks for taking the time to file this. I'll have to think about what if anything can be done about it. Maybe a YAML tag that flags the line as not to be warned about? A borgmatic option to disable the warnings altogether? Something else?
Author

What are your thoughts on these AI suggestions?

  • {{ and }}: In Python string formatting, doubling the braces escapes them.

  • %%: Depending on your shell environment, you may also need to double the percent sign if it's being interpreted by a shell wrapper, though usually, the {{name}} change is the primary fix for the borgmatic warning specifically.

I tried {{ }} but that broke the command and still had the warning from borgmatic. Not sure how to test without running borgmatic each time.

I would think finding and documenting how to escape the notation, if possible, makes more sense than changing borgmatic.

What are your thoughts on these AI suggestions? > - {{ and }}: In Python string formatting, doubling the braces escapes them. > > - %%: Depending on your shell environment, you may also need to double the percent sign if it's being interpreted by a shell wrapper, though usually, the {{name}} change is the primary fix for the borgmatic warning specifically. I tried {{ }} but that broke the command and still had the warning from borgmatic. Not sure how to test without running borgmatic each time. I would think finding and documenting how to escape the notation, if possible, makes more sense than changing borgmatic.
Owner

I would think finding and documenting how to escape the notation, if possible, makes more sense than changing borgmatic.

The interpolation and warning logic are both performed by borgmatic, so any escape notation would have to be implemented by changing borgmatic.

What are your thoughts on these AI suggestions?

{{ and }}: In Python string formatting, doubling the braces escapes them.

%%: Depending on your shell environment, you may also need to double the percent sign if it's being interpreted by a shell wrapper, though usually, the {{name}} change is the primary fix for the borgmatic warning specifically.

{{ and }} could maybe work, although then it might be a breaking change for anyone who has those literals in their existing commands. That could be okay if documented as such.

I don't think %% would be necessary.

I tried {{ }} but that broke the command and still had the warning from borgmatic.

Yeah, that's definitely not implemented currently.

Not sure how to test without running borgmatic each time.

You could move/copy the command hook to a borgmatic action other than create, just temporarily to make testing easier.

> I would think finding and documenting how to escape the notation, if possible, makes more sense than changing borgmatic. The interpolation and warning logic are both performed by borgmatic, so any escape notation would have to be implemented by changing borgmatic. > What are your thoughts on these AI suggestions? > > > * > > {{ and }}: In Python string formatting, doubling the braces escapes them. > > > > * > > %%: Depending on your shell environment, you may also need to double the percent sign if it's being interpreted by a shell wrapper, though usually, the {{name}} change is the primary fix for the borgmatic warning specifically. `{{` and `}}` could maybe work, although then it might be a breaking change for anyone who has those literals in their existing commands. That could be okay if documented as such. I don't think `%%` would be necessary. > I tried {{ }} but that broke the command and still had the warning from borgmatic. Yeah, that's definitely not implemented currently. > Not sure how to test without running borgmatic each time. You could move/copy the command hook to a borgmatic action other than `create`, just temporarily to make testing easier.
Owner

I have this working now using backslashes for escaping, e.g. \{name\}. This is consistent with how escaping is already done for environment variable interpolation. And as part of this work, I'm also implementing the same sort of escaping for constant interpolation.

I'm working on tests now to finish this up.

I have this working now using backslashes for escaping, e.g. `\{name\}`. This is consistent with how escaping is already done for environment variable interpolation. And as part of this work, I'm also implementing the same sort of escaping for constant interpolation. I'm working on tests now to finish this up.
Owner

Okay, this is implemented in main and will be part of the next release! Docs will be live shortly. Note that this is technically a breaking change, in that anyone who happens to already have \{name\} in their configuration will see that replaced with {name}. (And no, there's not currently a way to escape the escapes. πŸ˜…)

Thanks again for filing this.

Okay, this is implemented in main and will be part of the next release! Docs will be live shortly. Note that this _is_ technically a breaking change, in that anyone who happens to already have `\{name\}` in their configuration will see that replaced with `{name}`. (And no, there's not currently a way to escape the escapes. πŸ˜…) Thanks again for filing this.
Owner

Released in borgmatic 2.1.0!

Released in borgmatic 2.1.0!
Author

Can confirm: this variable warning is gone with borgmatic 2.1.0 !

Can confirm: this variable warning is gone with borgmatic 2.1.0 !
Sign in to join this conversation.
No milestone
No project
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#1213
No description provided.